Cod sursa(job #2540401)

Utilizator FrostfireMagirescu Tudor Frostfire Data 7 februarie 2020 09:44:02
Problema Restante Scor 100
Compilator cpp-64 Status done
Runda irim_eralumis Marime 0.67 kb
#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
#include <map>
#define NMAX 36000

using namespace std;

ifstream f("restante.in");
ofstream g("restante.out");

int n;
char t[20];
string s[NMAX+10];
map <string, int> m;

int main()
{
    f >> n;
    for(int i=1; i<=n; i++)
        {   f >> t;
            int len = strlen(t);
            sort(t, t+len);
            for(int j=0; j<len; j++) s[i].push_back(t[j]);
        }
    int sol = n;
    for(int i=1; i<=n; i++)
        {   m[s[i]]++;
            if(m[s[i]] == 2) sol -= 2;
            else if(m[s[i]] > 2) sol--;
        }
    g << sol << '\n';
    return 0;
}