Cod sursa(job #554336)

Utilizator tudorsTudor Siminic tudors Data 14 martie 2011 19:22:07
Problema Restante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <fstream>
#include <algorithm>
#define MA 18
using namespace std;
int N,i,n,rez,s;
int X[36001];
char A[36001][MA];
char Q[MA];

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

bool myfct(int a, int b)
{
	return (strcmp(A[a],A[b])<0);
}

int main()
{
	f>>N;
	f.get();
	for (i=0;i<N;++i)
	{
		f.getline(Q,MA);
		n=strlen(Q);
		X[i]=i;
		sort(Q,Q+n);
		strcpy(A[i],Q);
	}
	sort(X,X+N,myfct);
	rez=0;
	s=1;
	for (i=1;i<N;++i)
	{
		if (strcmp(A[X[i-1]],A[X[i]])==0)
			s++;
		else
		{
			if (s==1)
				rez++;
			s=1;
		}
	}
	if (s==1)
		rez++;
	g<<rez;
	f.close();
	g.close();
	return 0;
}