Cod sursa(job #132506)

Utilizator megabyteBarsan Paul megabyte Data 5 februarie 2008 23:07:21
Problema Restante Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#define NMAX 36002
#define INF "restante.in"
#define OUF "restante.out"
#define pb(arg) push_back(arg)
#define sz(arg) arg.size()
using namespace std;
vector<string> v;

int main()
{
	FILE *in,*out;
	in=fopen(INF,"r");
	out=fopen(OUF,"w");
	int i,n,k,sol;
	string aux;
	char buf[32];
	fscanf(in,"%d\n",&n);
	for(i=0;i<n;++i)
	{
		fgets(buf,32,in);
		k=strlen(buf);
		sort(buf,buf+k);
		aux=buf;
		v.pb(aux);
	}
	sort(v.begin(),v.end());
	sol=n;k=0;
	for(i=1;i<n;++i) 
	if(v[i]==v[i-1]) ++k;
	else if(k)
	{
		sol-=(k+1);
		k=0;
	}

	fprintf(out,"%d",sol);
	fclose(in);fclose(out);
	return 0;
}