Codeforces - Educational Codeforces Round 14B - s-palindrome(模拟)

B. s-palindrome
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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

题意:给出一个字符串,判断是否对称并为纯镜面对称

模拟呗,做的还是挺开心的,每次做模拟都很开心233333我这是什么神奇倾向

先找出纯镜面对称的所有字母和字母对,u和m不对称,略懵逼,仔细研究了一下确实不对称23333


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <iostream>
#include <assert.h>
#define INF 0x3f3f3f3f
using namespace std;


int main()
{
  char s[1005];
  while (scanf("%s", s) != EOF) {
    int flag = 0;
    for(int i = 0, j = strlen(s) - 1; i < strlen(s) / 2 + 1; i++, j--) {
      flag = 0;
      char aa = s[i];
      char bb = s[j];
      switch(aa) {
        case 'A':
        case 'H':
        case 'I':
        case 'M':
        case 'O':
        case 'o':
        case 'T':
        case 'U':
        case 'V':
        case 'v':
        case 'W':
        case 'w':
        case 'X':
        case 'x':
        case 'Y': flag = 1; break;
        case 'b': flag = 2; break;
        case 'p': flag = 3; break;
        case 'd': flag = 4; break;
        case 'q': flag = 5; break;
      }
      if(flag == 1 && aa == bb) continue;
      if(flag == 2 && bb == 'd') continue;
      if(flag == 3 && bb == 'q') continue;
      if(flag == 4 && bb == 'b') continue;
      if(flag == 5 && bb == 'p') continue;
      if(strlen(s) % 2 && i == strlen(s) / 2 + 1 && flag != 1) flag = 6;
      flag = 6; break;
    }
    if(flag != 6) printf("TAK\n");
    else printf("NIE\n");
  }
  return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值