Created
February 17, 2017 03:58
-
-
Save dada8397/d4b61a4f0bcd4f7c5108e4887eaf065f to your computer and use it in GitHub Desktop.
UVa 10420 - List of Conquests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <map> | |
#include <cstring> | |
#include <cstdio> | |
#include <iostream> | |
using namespace std; | |
int main(void) { | |
int n; | |
while(scanf("%d\n", &n) != EOF) { | |
char line[100]; | |
map<string, int> m; | |
for(int i=0; i<n; i++) { | |
fgets(line, 100, stdin); | |
char *country = strtok(line, " "); | |
m[country]++; | |
} | |
for(map <string, int>::iterator it = m.begin(); it != m.end(); it++) { | |
cout << it->first << " " << it->second << endl; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment