1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <bits/stdc++.h> #define ll long long #define ld long double #define N 24 #define FOR(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> using namespace std;
bool cmp(pii a,pii b){ if(a.second==b.second)return a.first>b.first; else return a.second< b.second; }
int main(){ string s; while(getline(cin,s)){ map<int,int> mp; for(auto temp:s)mp[temp]+=1; vector<pii>vec; for(auto p:mp){ vec.push_back(p); } sort(vec.begin(),vec.end(),cmp); for(auto i:vec){ cout<<i.first<<" "<<i.second<<endl; } cout<<endl; } }
|