Cod sursa(job #340360)

Utilizator ancaaaancaaa ancaaa Data 14 august 2009 13:30:37
Problema Restante Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>

using namespace std;

#define N 36000

struct ltstr{
	bool operator()(char* s1, char* s2) {
		return strcmp(s1, s2)<0;
	}
};

ifstream inFile;
ofstream outFile;
map<char*, int, ltstr> words; // red black tree
int n;

int main() {
	char* str;
	inFile.open("restante.in",ios::in);
	outFile.open("restante.out",ios::out);

	if (inFile.is_open() == 0) {
		cerr<<"Unable to open file for input.";
		exit(1);
	}

	if (outFile.is_open() == 0) {
		cerr<<"Unable to open file for output.";
		exit(1);
	}

	inFile>>n;

	for (int i=1; i<=n; i++) {
		str=new char(16);
		inFile>>str;
		sort(str+0, str+strlen(str));
		words[str]++;
	}
	
	int nr=0;
	for(map<char*, int, ltstr>::iterator ii=words.begin(); ii!=words.end(); ++ii) {	
		if (ii->second == 1)
			nr++;
	}

	outFile<<nr;
	inFile.close();
	outFile.close();
	words.clear();

	return 0;
}