Advertisement
Guest User

Referência para 10420 (Luiza)

a guest
Feb 27th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <map>
  3. #include <string>
  4. #include <set>
  5. using namespace std;
  6.  
  7. map<string,int> m;
  8. set<string> s;
  9. char name[510], country[510];
  10. int n;
  11.  
  12. int main() {
  13.     scanf("%d", &n);
  14.  
  15.     for (int i=0; i<n; i++) {
  16.         scanf(" %s %[^\n]", country,name);
  17.        
  18.         if (s.find(name)==s.end()) {
  19.             s.insert(name);
  20.             m[country]++;
  21.         }
  22.     }
  23.    
  24.     for (map<string,int>::iterator it = m.begin(); it!=m.end(); ++it)
  25.         printf("%s %d\n", it->first.c_str(), it->second);
  26.    
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement