Cod sursa(job #1811361)

Utilizator stefanst77Luca Stefan Ioan stefanst77 Data 21 noiembrie 2016 10:08:56
Problema Restante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <bits/stdc++.h>

using namespace std;

struct Db
{
    char cuv[20];
};
Db t[36006];
char aux[20];
int n;

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

void Citire()
{
    fin >> n;
    int i;
    for(i = 1; i <= n; i++)
    {
        fin >> aux;
        sort(aux, aux+strlen(aux));
        strcpy(t[i].cuv, aux);
    }
}

inline bool Cmp(const Db A, const Db B)
{
    return strcmp(A.cuv, B.cuv) < 0;
}
void Rezolva()
{
    int i;
    sort(t, t+n+1, Cmp);

    int sol = n;

    for(i = 1; i <= n; i++)
        if(strcmp(t[i].cuv, t[i-1].cuv)==0 || strcmp(t[i].cuv, t[i+1].cuv) == 0)
         sol --;

    fout << sol;

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

int main()
{
    Citire();
    Rezolva();
    return 0;
}