Cod sursa(job #1811320)

Utilizator loo_k01Luca Silviu Catalin loo_k01 Data 21 noiembrie 2016 09:31:55
Problema Restante Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <bits/stdc++.h>

using namespace std;
char cuv[36006][20];
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(cuv[i], aux);
    }
}

void Rezolva()
{
    int i, j;

    for(i = 1; i < n; i++)
        for(j = i + 1; j <= n; j++)
        {
            if(strcmp(cuv[i], cuv[j]) > 0)
            {
                strcpy(aux, cuv[i]);
                strcpy(cuv[i], cuv[j]);
                strcpy(cuv[j], aux);
            }
        }
    int sol = 0;
    for(i = 2; i <= n; i++)
    {
        if(strcmp(cuv[i], cuv[i-1]) != 0)
            sol++;
    }
    fout << sol;
    fin.close();
    fout.close();
}

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