2017/3/21

10420:List of Conquests

//http://bit.ly/2nzLF1m
#include <iostream>
#include <map>
using namespace std;

int main() {
    int n;
    map<string, int> record;
    map<string, int>::iterator i;
    
    while (cin>>n && n!=1) {
        string country, tmp;
        while (n--) {
            cin >> country;
            record[country]++;
            getline(cin, tmp);
        }
        for ( i = record.begin(); i != record.end(); i++)
            cout << i->first << " " << i->second << endl;
    }
    return 0;
}
題目網址:http://bit.ly/2nzLF1m

沒有留言:

張貼留言