Cod sursa(job #936948)

Utilizator claudiumihailClaudiu Mihail claudiumihail Data 9 aprilie 2013 10:29:39
Problema Restante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.37 kb
#include <fstream>
#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>
#include <ext/hash_map>

#define MAX_WORD_SIZE 16
#define MAXN 36003

using namespace std;
using namespace __gnu_cxx;

namespace __gnu_cxx
{
        template<> struct hash< std::string >
        {
                size_t operator()( const std::string& x ) const
                {
                        return hash< const char* >()( x.c_str() );
                }
        };
}


typedef hash_map<string, unsigned short> string_hash_map;

string_hash_map hmUniques;

int main()
{
    int n;
    short table[26];
    string word;
    fstream fin("restante.in", fstream::in);
    fstream fout("restante.out", fstream::out);
    
    fin >> n;
    //cout << n << endl;
    
    for (int i=0; i<n; ++i)
    {
        fin >> word;
        //cout << word << " ";
        
        sort(word.begin(), word.end());
        //cout << word << endl;
        
        hmUniques[word]++;
    }
    
    unsigned short numUniques = 0;
    for (string_hash_map::const_iterator it = hmUniques.begin();
         it != hmUniques.end();
         it++)
    {
        //cout << it->first << " " << it->second << endl;
        if (it->second == 1)
        {
            numUniques++;
        }
    }
    
    fout << numUniques << "\n";
    
    
    return 0;
}