s-palindrome
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
You are given a string s. Check if the string is "s-palindrome".
Input
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Output
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
Examples
input
oXoxoXo
output
TAK
input
bod
output
TAK
input
ER
output
NIE
分析:考眼力题;
代码:
#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <algorithm> #include <climits> #include <cstring> #include <string> #include <set> #include <map> #include <queue> #include <stack> #include <vector> #include <list> #include <ext/rope> #define rep(i,m,n) for(i=m;i<=n;i++) #define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++) #define vi vector<int> #define pii pair<int,int> #define inf 0x3f3f3f3f #define pb push_back #define mp make_pair #define fi first #define se second #define ll long long #define pi acos(-1.0) const int maxn=7e5+10; const int mod=1e6+3; const int dis[4][2]={{0,1},{-1,0},{0,-1},{1,0}}; using namespace std; using namespace __gnu_cxx; ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);} ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;} int n,m,cnt,ok; map<char,int>a; string b; bool check(char p,char q) { if(p>q)swap(p,q); if(p=='b'&&q=='d')return true; if(p=='p'&&q=='q')return true; return false; } int main() { int i,j,k,t; cin>>b; a['A']=1,a['H']=1,a['I']=1,a['M']=1,a['M']=1,a['O']=1,a['o']=1,a['T']=1,a['U']=1,a['V']=1,a['v']=1,a['W']=1,a['w']=1,a['X']=1,a['x']=1,a['Y']=1; int len=b.length(); rep(i,0,len/2)if((!a[b[i]]||b[i]!=b[len-1-i])&&!check(b[i],b[len-1-i]))return 0*puts("NIE"); puts("TAK"); //system ("pause"); return 0; }