Skip to content

Instantly share code, notes, and snippets.

@dada8397
Created February 17, 2017 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dada8397/d4b61a4f0bcd4f7c5108e4887eaf065f to your computer and use it in GitHub Desktop.
Save dada8397/d4b61a4f0bcd4f7c5108e4887eaf065f to your computer and use it in GitHub Desktop.
UVa 10420 - List of Conquests
#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