Cod sursa(job #2396455)

Utilizator Theo20067Cismaru Theodor-Alexe Theo20067 Data 3 aprilie 2019 15:14:12
Problema Restante Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <fstream>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,i,j;
char a[36001][17];
int p[36001],sol;
int cmp(int i, int j)
{
    return strcmp(a[i], a[j]) < 0;
}
int main ()
{
    ifstream fin ("restante.in");
    ofstream fout("restante.out");
    fin>>n;
    for (i=1;i<=n;i++)
    {
        fin>>a[i];
        sort(a[i],a[i]+strlen(a[i]));
    }
    for(i=1;i<=n;i++)
    {
        p[i]=i;
    }
    sort(p+1,p+n+1,cmp);
    if(strcmp(a[p[1]],a[p[2]])!=0)
    {
        sol++;
    }
    if(strcmp(a[p[n]],a[p[n-1]])!=0)
    {
        sol++;
    }
    for(i=2;i<n;i++)
        if((strcmp(a[p[i]],a[p[i-1]]))!=0&&(strcmp(a[p[i]],a[p[i+1]]))!=0)
            sol++;
    fout<<sol;
    return 0;
}