题解 | 小红的回文串
小红的回文串
https://www.nowcoder.com/practice/b0c3a7aecb0a47ab865602585f4402a7
#include <iostream> #include<string> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin>>t; string s,_s; while(t--){ cin>>s; _s=""; int k=1; for(char ch:s){ if(ch=='d'||ch=='p'||ch=='q') _s+='b'; else if(ch=='w') _s+="vv"; else if(ch=='m') _s+="uu"; else if(ch=='n') _s+='u'; else _s+=ch; } int left=0,right=_s.size()-1; while(left<right){ if(_s[left]!=_s[right]){ k=0; break; } left++; right--; } if(k==0) cout<<"NO\n"; else cout<<"YES\n"; } } // 64 位输出请用 printf("%lld")