題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1361
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #include <iostream> #include <sstream> #include <vector> #include <string> #include <map>
using namespace std;
int main(){ int n; cin >> n >> ws; string text; map<string, int> m; while(n--){ getline(cin, text); stringstream ss(text); string country; ss >> country; m[country]++; } for(const auto& p : m){ cout << p.first << " " << p.second << '\n'; } }
|