Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <map>
- #include <string>
- #include <set>
- using namespace std;
- map<string,int> m;
- set<string> s;
- char name[510], country[510];
- int n;
- int main() {
- scanf("%d", &n);
- for (int i=0; i<n; i++) {
- scanf(" %s %[^\n]", country,name);
- if (s.find(name)==s.end()) {
- s.insert(name);
- m[country]++;
- }
- }
- for (map<string,int>::iterator it = m.begin(); it!=m.end(); ++it)
- printf("%s %d\n", it->first.c_str(), it->second);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement