Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. FME > FIB
  2.  
  3. P30170
  4.  
  5. #include <iostream>
  6. #include <map>
  7. using namespace std;
  8.  
  9. int main(){
  10.     int n;
  11.     while (cin >> n){
  12.         string s;
  13.         map<string, int> m;
  14.         for (int i = 0; i < n; i++){
  15.             cin >> s;
  16.             ++m[s];
  17.         }
  18.         map<string, int>::iterator it;
  19.         map<int, int> m2;
  20.         for (it = m.begin(); it != m.end(); it++){
  21.             m2[it->second]+=(it->first).length();
  22.         }  
  23.         map<int, int>:: iterator it2;
  24.         for (it2 = m2.begin(); it2 != m2.end(); it2++){
  25.             cout << it2->first << " : " << (it2->second)<< endl;
  26.         }
  27.         cout << endl;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement