鬼畜UVA - 401每日一题·猛男就是要暴力打表

Posted suut

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鬼畜UVA - 401每日一题·猛男就是要暴力打表相关的知识,希望对你有一定的参考价值。

 

管他什么rev数组,msg数组简化代码

#define _CRT_SECURE_NO_WARNINGS
#include    <cmath>
#include <iostream>
#include    <stdio.h>
#include<algorithm>
#include        <map>
#include     <cstring>
#include      <time.h>
#include      <string>
using namespace std;
#define rep(i,t,n)  for(int i =(t);i<=(n);++i)
#define per(i,n,t)  for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
const int maxn = 20 + 5;
const long long mod = 1e9 + 7;
int n; int sum = 0;
int a[maxn]; int vis[maxn];
bool cmp(int a, int b) { return a > b; }
char M[256];


bool mirror(string s) {
    int len = s.length();
    rep(i, 0, len - 1) {
        if (s[i] != M[s[len-1 - i]])return 0;
    }
    return 1;
}
bool palin(string s) {
    int len = s.length();
    rep(i, 0, len - 1) {
        if (s[i] != s[len-1 - i])return 0;
    }
    return 1;
}

int main() {    
    M[A] = A; M[E] = 3; M[M] = M; M[O] = O; M[S] = 2; M[T] = T; M[U] = U; M[V] = V; M[W] = W; M[X] = X; M[Y] = Y; M[Z] = 5; M[1] = 1; M[2] = S; M[3] = E; M[5] = Z; M[8] = 8; M[L] = J;    M[J] = L; M[I] = I; M[H] = H;
    string ss;
    
    while (cin>>ss) {
        int f1 = 0, f2 = 0;
        if (mirror(ss))f1 = 1;
        if (palin(ss))f2 = 1;
        cout << ss;
        if (f1&&f2)puts(" -- is a mirrored palindrome.");
        else if (f1 && !f2)puts(" -- is a mirrored string.");
        else if (!f1&&f2)puts(" -- is a regular palindrome.");
        else puts(" -- is not a palindrome.");
        cout << endl;
    }
    

    //cin >> n;
}

/*
3
4 1 1 1 1
5 10 20 30 40 50
8 1 7 2 6 4 4 3 5

1
3
1 1 2
A    A    M    M    Y    Y
B         N         Z    5
C         O    O    1    1
D         P         2    S
E    3    Q         3    E
F         R         4
G         S    2    5    Z
H    H    T    T    6
I    I    U    U    7
J    L    V    V    8    8
K         W    W    9
L    J    X    X
*/

 

以上是关于鬼畜UVA - 401每日一题·猛男就是要暴力打表的主要内容,如果未能解决你的问题,请参考以下文章

《LeetCode之每日一题》:183.最小操作次数使数组元素相等

每日一题 UVA - 340 阅读理解+模拟

每日一题 UVA - 213 Message Decoding 模拟解码+读入函数+阅读题

每日一题 UVA - 1599 Ideal Path 字典序最短路

回文词 (Palindromes,Uva401)

回文词(Palindromes, UVa401)