Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <string>
  6. #include <unordered_map>
  7. #include <map>
  8. #include <queue>
  9. #include <unordered_set>
  10. using namespace std;
  11.  
  12. typedef long long int ll;
  13.  
  14. bool contain(string a, char b)
  15. {
  16. for (int i=0; i<a.size(); i++)
  17. if (a[i]>-5&&a[i]<30) return true;
  18. return false;
  19. }
  20.  
  21. bool compare(pair <int, string> a, pair <int, string> b)
  22. {
  23. if (a.first>b.first) return true;
  24. if (a.first<b.first) return false;
  25. if (a.first == b.first && a.second>b.second) return false;
  26. if (a.first == b.first && a.second<b.second) return true;
  27. return false;
  28. }
  29.  
  30. int main(){
  31.  
  32. char end = -1;
  33.  
  34. unordered_map <string, int> m;
  35. string a;
  36. while(cin>>a){
  37. m[a]++;}
  38.  
  39. vector <pair<int, string> > res;
  40.  
  41. for (auto it=m.begin(); it != m.end(); it++)
  42. {
  43. res.push_back(make_pair(it->second, it->first));
  44. }
  45.  
  46. sort (res.begin(), res.end(), compare);
  47.  
  48. for (int i=0; i<res.size(); i++)
  49. cout<<res[i].second<<endl;
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement