Cod sursa(job #514426)

Utilizator ChallengeMurtaza Alexandru Challenge Data 18 decembrie 2010 18:09:16
Problema Restante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <fstream>
#include <string>
#include <algorithm>

using namespace std;

const char InFile[]="restante.in";
const char OutFile[]="restante.out";
const int MaxN=36111;

ifstream fin(InFile);
ofstream fout(OutFile);

int N,sol;
string v[MaxN];

int main()
{
	fin>>N;
	for(register int i=0;i<N;++i)
	{
		fin>>v[i];
		sort(v[i].begin(),v[i].end());
	}
	sort(v,v+N);

	int ind=0;
	while(ind<N)
	{
		int next=ind+1;
		if(next>=N)
		{
			next=N;
		}
		int prev=ind-1;
		if(prev<0)
		{
			prev=0;
		}
		if((next==ind || v[ind]!=v[next]) && (v[ind]!=v[prev] || prev==ind))
		{
			++sol;
		}
		++ind;
	}

	fout<<sol;
	fout.close();
	return 0;
}