模拟Codeforces 691B s-palindrome

Posted Coolxxx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模拟Codeforces 691B s-palindrome相关的知识,希望对你有一定的参考价值。

题目链接:

  http://codeforces.com/problemset/problem/691/B

题目大意:

  求一个字符串是不是镜像的(不是回文)。是输出TAK否则RE。

题目思路:

  【模拟】

  预处理镜像的字母,注意bd pq,从头尾开始模拟。

 

 

 1 //
 2 //by coolxxx
 3 //#include<bits/stdc++.h>
 4 #include<iostream>
 5 #include<algorithm>
 6 #include<string>
 7 #include<iomanip>
 8 #include<map>
 9 #include<stack>
10 #include<queue>
11 #include<set>
12 #include<bitset>
13 #include<memory.h>
14 #include<time.h>
15 #include<stdio.h>
16 #include<stdlib.h>
17 #include<string.h>
18 //#include<stdbool.h>
19 #include<math.h>
20 #define min(a,b) ((a)<(b)?(a):(b))
21 #define max(a,b) ((a)>(b)?(a):(b))
22 #define abs(a) ((a)>0?(a):(-(a)))
23 #define lowbit(a) (a&(-a))
24 #define sqr(a) ((a)*(a))
25 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
26 #define mem(a,b) memset(a,b,sizeof(a))
27 #define eps (1e-8)
28 #define J 10
29 #define mod 1000000007
30 #define MAX 0x7f7f7f7f
31 #define PI 3.14159265358979323
32 #define N 204
33 using namespace std;
34 typedef long long LL;
35 int cas,cass;
36 int n,m,lll,ans;
37 bool a[N][N];
38 char s[1004];
39 int main()
40 {
41     #ifndef ONLINE_JUDGE
42 //    freopen("1.txt","r",stdin);
43 //    freopen("2.txt","w",stdout);
44     #endif
45     int i,j,k;
46 //    for(scanf("%d",&cass);cass;cass--)
47 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
48     while(~scanf("%s",s))
49 //    while(~scanf("%d",&n))
50     {
51         a[\'A\'][\'A\']=a[\'H\'][\'H\']=a[\'I\'][\'I\']=a[\'M\'][\'M\']=a[\'O\'][\'O\']=a[\'o\'][\'o\']=a[\'T\'][\'T\']=a[\'V\'][\'V\']=a[\'U\'][\'U\']=a[\'v\'][\'v\']=a[\'W\'][\'W\']=a[\'w\'][\'w\']=a[\'X\'][\'X\']=a[\'x\'][\'x\']=a[\'Y\'][\'Y\']=1;
52         a[\'b\'][\'d\']=a[\'d\'][\'b\']=a[\'p\'][\'q\']=a[\'q\'][\'p\']=1;
53         n=strlen(s);
54         for(i=0,j=n-1;i<=j;i++,j--)
55         {
56             if(!a[s[i]][s[j]])break;
57         }
58         if(i<=j)puts("NIE");
59         else puts("TAK");
60     }
61     return 0;
62 }
63 /*
64 //
65 
66 //
67 */
View Code

 

以上是关于模拟Codeforces 691B s-palindrome的主要内容,如果未能解决你的问题,请参考以下文章

CodeForces 2A - Winner(模拟)

codeforces——模拟

Codeforces 747C:Servers(模拟)

codeforces 591B Rebranding (模拟)

Codeforces 892B Wrath(模拟)

codeforces 915 C(思维+模拟)