fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define faster() ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  5. bool checktn(string a){
  6. string s=a;
  7. reverse(a.begin(), a.end());
  8. if(a==s) return true;
  9. return false;
  10. }
  11. struct cmp{
  12. bool operator () (string a, string b){
  13. if(a.size()==b.size()) return a>b;
  14. else return a.size()>b.size();
  15. }
  16. };
  17. int main(){
  18. faster();
  19. map<string, int, cmp> mp;
  20. string s;
  21. while(cin>>s){
  22. if(checktn(s)&&s.size()>2) mp[s]++;
  23. }
  24. for(auto it: mp){
  25. cout<<it.first<<" "<<it.second<<endl;
  26. }
  27. }
Success #stdin #stdout 0s 5268KB
stdin
Standard input is empty
stdout
Standard output is empty