Cod sursa(job #3277279)

Utilizator Gergo123Schradi Gergo Gergo123 Data 15 februarie 2025 16:16:02
Problema Restante Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <iostream>
#include <fstream>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main() {
    ifstream fin("restante.in");
    ofstream fout("restante.out");

    if (!fin || !fout) {
        cerr << "Eroare la deschiderea fisierului!\n";
        return 1;
    }

    int N;
    fin >> N;

    unordered_set<string> uniqueWords;

    for (int i = 0; i < N; i++) {
        string word;
        fin >> ws >> word;  // Elimină spațiile accidentale
        sort(word.begin(), word.end());
        uniqueWords.insert(word);
    }

    fout << uniqueWords.size() << "\n";

    fin.close();
    fout.close();
    return 0;
}