UVa 10420 – List of Conquests

#include <iostream>
#include <string>
#include <map>
#include <utility>

using namespace std;

int main(){
    map <string, int> hashMap;
    map < string , int>::iterator it;

    int t;
    string s,spare;
    cin>>t;

    while (t--){
        cin>>s;
        getline(cin,spare);

        if(hashMap.find(s)!=hashMap.end())
            hashMap[s]++;
        else
            hashMap[s] = 1;

    }
    for(it = hashMap.begin() ; it!=hashMap.end() ; it++)
        cout<<(*it).first<<" "<<(*it).second<<endl;

    return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s