B. s-palindrome(模拟)

CF链接:http://codeforces.com/contest/691/problem/B

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.

English alphabet

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

题意:要求对称的回文字符串,我们要知道哪个字母是轴对称的:

A H I M O o T U V v W w x X Y

特殊的还有p,q和b,d注意一下。

#include<iostream>
using namespace std;
int check(char s)
{
    if(s=='A'||s=='H'||s=='I'||s=='M'||s=='O'||s=='o')
        return 1;
    if(s=='T'||s=='U'||s=='V'||s=='v'||s=='W'||s=='w')
        return 1;
    if(s=='X'||s=='x'||s=='Y')
        return 1;
    return 0;
}
int main()
{
    string s;
    cin>>s;
    int flag=1;
    int len=s.size();
    for(int i=0;i<=len/2-1;i++)
    {
        if(s[i]!=s[len-1-i])
        {
            if(s[i]=='p'&&s[len-1-i]=='q')
                continue;
            if(s[i]=='b'&&s[len-1-i]=='d')
                continue;
            if(s[i]=='q'&&s[len-1-i]=='p')
                continue;
            if(s[i]=='d'&&s[len-1-i]=='b')
                continue;
            flag=0;
            break;
        }
        if(check(s[i])==0)
        {
            flag=0;
            break;
        }
    }
    if(len%2==1)
    {
        if(check(s[len/2])==0)
            flag=0;
    }
    if(flag==1)
        cout<<"TAK"<<endl;
    else
        cout<<"NIE"<<endl;
    return 0;
}
/*
A H I   M   O o T U  V v W w x X Y
*/

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值