// #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432 // 模拟题,详细请见代码注释 #include <iostream> #include <algorithm> #include <string> #include <map> using namespace std; map<char, int> cnt; bool check(string s){//----------------检查除中间之外的值是否轴对称 int i = 0, j = s.size() - 1; int endpoint = s.size() / 2; while(i < endpoint){ if (s[i] != s[j] || s[i] == 'b' || s[i] == 'q' || s[i] == 'd' || s[i] == 'p'){//------这里注意b、q、d、p的特判 int ls = cnt[s[i]] + cnt[s[j]]; if (ls != 3 && ls != 7) return 1;//--------这里我为了省力用了数值,也可以一个一个判断只是要写很多字 } i++; j--; } return 0; } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n; cin >> n; map<char, bool> ma; string s = "ilmnouvwx"; for (int i = 0; i < s.size(); i++){ ma[s[i]] = true; } #define yy "Yes"//--------为了少打一点字 #define nn "No" cnt['q'] = 1; cnt['p'] = 2; cnt['b'] = 3; cnt['d'] = 4; for (int i = 0; i < n; i++){ cin >> s; if (check(s)){//-------------如果周边部分有非轴对称,则nn cout << nn << endl; } else { if (s.size() & 1){//------------奇数判断中间 if (ma[s[s.size() / 2]]){//------用了map标记 cout << yy << endl; } else { cout << nn << endl; } } else {//----------偶数,yy cout << yy << endl; } } } } // 64 位输出请用 printf("%lld")