Cod sursa(job #1555164)

Utilizator daniel.grosuDaniel Grosu daniel.grosu Data 22 decembrie 2015 13:10:08
Problema Restante Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include<fstream>
#include<string.h>
#include<map>
using namespace std;

ifstream cin("restante.in");
ofstream cout("restante.out");

map<long long, bool> H;
short viz[30];

string a;
int n;
int rs;
unsigned long h;
int main()
{
	cin>>n;
	for(int i=1; i<=n; ++i)
	{
		cin>>a;
		for(int j=0; j<27; ++j)
			viz[j]=0;
			
		for(int k=0; k<a.size(); ++k)
			viz[a[k]-'a']++;
			
		h = 5381;
		
		for(int j=0; j<27; ++j)
			h = ((h << 5) + h) + viz[j];
			
		if(!H[h])
		{
			rs++;
			H[h]=true;
		}else
			rs--;
	}
	cout<<rs;
}