Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <cctype>
  3. #include <cstdio>
  4. #include <iostream>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <stack>
  9. #include <queue>
  10. #include <string>
  11. #include <cmath>
  12. #include <iomanip>
  13. #include <algorithm>
  14.  
  15. #define fori(start,end) for (int i = start; i < end;i++)
  16. #define forj(start,end) for (int j = start; j < end;j++)
  17. #define all(arr) arr.begin(),arr.end()
  18. #define nline printf("\n")
  19. #define pb push_back
  20. #define veci vector<int>
  21. #define vecb vector<bool>
  22. #define vecl vector<long long>
  23. #define vecpi vector<pair<int,int>>
  24. #define vecveci vector<vector<int>>
  25. #define vecd vector<double>
  26. #define vecs vector<string>
  27. typedef long long ll;
  28. using namespace std;
  29.  
  30. const int INF = 1e9+5;
  31. const ll inf = 1e18;
  32. const double PI = 3.1415926535897932384626433832795;
  33.  
  34. ll gcd(ll a, ll b){
  35.     if(b == 0) return a;
  36.     return gcd(b,a%b);
  37. }
  38.  
  39. bool cmp(pair<int,string>&a,pair<int,string>&b){
  40.     return a.first > b.first || a.first == b.first && a.second < b.second;
  41. }
  42.  
  43. int main(){
  44.     freopen("input.txt","r",stdin);
  45.     string s;
  46.     map<string,int> mp;
  47.     while(cin >> s){
  48.         mp[s]++;
  49.     }
  50.     vector<pair<int,string>> ans;
  51.     for(auto it = mp.begin();it != mp.end();++it){
  52.         ans.pb({it->second,it->first});
  53.     }
  54.     sort(all(ans),cmp);
  55.     for(auto&i:ans){
  56.         printf("%s\n",i.second.c_str());
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement