Mirrored String I Gym

来源:互联网 发布:sm4算法介绍 编辑:程序博客网 时间:2024/05/17 22:01

https://vjudge.net/contest/159763#problem/H

判断是不是由指定字符组成的回文串

////  main.cpp//  160929////  Created by 刘哲 on 17/4/13.//  Copyright © 2016年 my_code. All rights reserved.////#include <bits/stdc++.h>#include <iostream>#include <algorithm>#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <string.h>#include <map>#include <set>#include <queue>#include <deque>#include <list>#include <bitset>#include <stack>#include <stdlib.h>#define lowbit(x) (x&-x)using namespace std;map<char,int>mp;int main(){    int n;    cin>>n;    //A, H, I, M, O, T, U, V, W, X, Y    mp['A']=1;    mp['H']=1;    mp['I']=1;    mp['M']=1;    mp['O']=1;    mp['T']=1;    mp['U']=1;    mp['V']=1;    mp['W']=1;    mp['X']=1;    mp['Y']=1;    while(n--){        string s;        cin>>s;        int flag = 1;        for(int i=0;i<s.length();i++){            if(mp[s[i]]&&s[i]==s[s.length()-1-i])            {                continue;            }            flag = 0;            break;        }        if(flag)            cout<<"yes"<<endl;        else            cout<<"no"<<endl;    }    return 0;}


0 0
原创粉丝点击