The gorillas have recently discovered that the image on the surface of the water is actually a reflection of themselves. So, the next thing for them to discover is mirrored strings.
A mirrored string is a palindrome string that will not change if you view it on a mirror.
Examples of mirrored strings are "MOM", "IOI" or "HUH". Therefore, mirrored strings must contain only mirrored letters {A, H, I, M, O, T, U, V, W, X, Y} and be a palindrome.
e.g. IWWI, MHHM are mirrored strings, while IWIW, TFC are not.
A palindrome is a string that is read the same forwards and backwards.
Can you tell if string S is a mirrored string?
Input
The first line of input is T – the number of test cases.
Each test case contains a non-empty string S of maximum length 1000. The string contains only uppercase English letters.
Output
For each test case, output "yes" (without quotes) if the string S is a mirrored string, otherwise output "no".
Example
Input
3 IOI ARABELLA RACECAR
Output
yes no no
题意:判断字符串是否是回文的,且都为镜像字母!
#include <iostream>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<stdio.h>
using namespace std;
typedef long long ll;
int check(char s)
{
if(s=='A'||s=='H'||s=='I'||s=='M'||s=='O')
return 1;
if(s=='T'||s=='U'||s=='V'||s=='W'||s=='X'||s=='Y')
return 1;
return 0;
}
int main()
{
int t;
cin>>t;
string s;
while(t--)
{
cin>>s;
int len=s.size();
int flag=0;
for(int i=0;i<len/2;i++)
{
if(check(s[i])&&s[i]==s[len-1-i])
continue;
flag=1;
}
if(len%2==1)//注意特判奇数,因为上面没考虑奇数的最中间那个字母
{
if(!check(s[len/2]))
flag=1;
}
if(flag==0)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}