Description
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".
Sample Input
3 IOI ARABELLA RACECAR
Sample Output
yes no no
题解:查找含相应字母的回文串。
代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#define For(i,n) for(int i=0;i<n;i++)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn = 1e5+5;
const double Pi = acos(-1);
const int INF = 0x3f3f3f3f;
typedef long long ll;
char a[1111];
int main()
{
int t;
cin>>t;
while(t--)
{
memset(a,0,sizeof(a));
cin>>a;
int l=strlen(a),flag1=0;
for(int i=0; i<l; i++)
if(a[i]!='A'&&a[i]!='H'&&a[i]!='I'&&a[i]!='M'&&a[i]!='O'&&a[i]!='T'&&a[i]!='U'&&a[i]!='V'&&a[i]!='W'&&a[i]!='X'&&a[i]!='Y')
{
flag1=1;
break;
}
int flag2=0;
for(int i=0; i<l/2; i++)
if(a[i]!=a[l-i-1])
{
flag2=1;
break;
}
if(!flag1&&!flag2)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}