Cod sursa(job #413184)

Utilizator pykhNeagoe Alexandru pykh Data 7 martie 2010 21:22:37
Problema Restante Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const char in[]="restante.in", out[]="restante.out";

struct cuv{ char c[17];bool x;}v[36005];

struct cmp{
	bool operator()(const char &a, const char &b)
	{
		return a<b;
	}
};

struct cmp1{
	bool operator()(const cuv &a, const cuv &b)
	{
		return strcmp(a.c, b.c) > 0 ? 0 : 1;
	}
};


int main()
	{
		freopen(in,"r",stdin);
		freopen(out,"w",stdout);
		int n;
		char aux[17];
		scanf("%d\n", &n);
		int s = n;
		for(int i=0;i<n;++i)
		{memset(aux, 0,  sizeof(aux));
			scanf("%s", aux);
			sort(aux, aux + strlen(aux), cmp());
			strcpy(v[i].c, aux);
		}
		sort(v, v+n, cmp1());
		for(int i = 0; i < n - 1; ++i)
			{if(!strcmp(v[i].c, v[i+1].c))v[i].x=1, v[i+1].x=1;
			if(v[i].x)--s;}
		printf("%d\n", s);
		return 0;
}