// UVa 10420 - List of Conquests
#include <iostream>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
using namespace std;
struct par {
string s;
int i;
};
bool operator <(const par & a, const par & b) {
return a.s < b.s;
}
int main() {
int n;
cin >> n;
string line;
getline(cin, line);
map<string, int> m;
for (int i = 0; i < n; i++) {
getline(cin, line);
istringstream strm(line);
string country;
strm >> country;
m[country]++;
}
vector<par> v;
for (map<string, int>::const_iterator I = m.begin(); I != m.end(); I++) {
par p = { I->first, I->second };
v.push_back(p);
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++)
cout << v[i].s << " " << v[i].i << endl;
return 0;
}
Wednesday, July 29, 2015
UVa 10420 - List of Conquests
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment