Cod sursa(job #340373)

Utilizator blasterzMircea Dima blasterz Data 14 august 2009 13:50:40
Problema Restante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.2 kb
                                                                     
                                                                     
                                                                     
                                             
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

#define N 36001

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

ifstream inFile;
ofstream outFile;
map<string, int> 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++) {
		
		string str;
		inFile>>str;
		sort(str.begin(), str.end());
		words[str]++;
	}
	
	int nr=0;
	for(map<string, int>::iterator ii=words.begin(); ii!=words.end(); ++ii) {	
		if (ii->second == 1)
			nr++;
	}

	outFile<<nr<<"\n";
	inFile.close();
	outFile.close();
	words.clear();

	return 0;
}