C++

 avatar
unknown
plain_text
2 years ago
1.8 kB
4
Indexable
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
void createTable(map<char, string> &table) {
    table['A'] = "01";
    table['B'] = "1000";
    table['C'] = "1010";
    table['D'] = "100";
    table['E'] = "0";
    table['F'] = "0010";
    table['G'] = "110";
    table['H'] = "0000";
    table['I'] = "00";
    table['J'] = "0111";
    table['K'] = "101";
    table['L'] = "0100";
    table['M'] = "11";
    table['N'] = "10";
    table['O'] = "111";
    table['P'] = "0110";
    table['Q'] = "1101";
    table['R'] = "010";
    table['S'] = "000";
    table['T'] = "1";
    table['U'] = "001";
    table['V'] = "0001";
    table['W'] = "011";
    table['X'] = "1001";
    table['Y'] = "1011";
    table['Z'] = "1100";
    table['1'] = "01111";
    table['2'] = "00111";
    table['3'] = "00011";
    table['4'] = "00001";
    table['5'] = "00000";
    table['6'] = "10000";
    table['7'] = "11000";
    table['8'] = "11100";
    table['9'] = "11110";
    table['0'] = "11111";
}
bool check(string s) {
    if (s.size() == 0)
        return false;
    int i = 0;
    int j = s.size() - 1;
    while (i < j) {
        if (s[i] != s[j])
            return false;
        i++;
        j--;
    }
    return true;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    map<char, string> table;
    createTable(table);
    string s;
    cin >> s;
    string res;
    for (int i = 0; i < s.size(); i++)
        if ((s[i] <= 'Z' && s[i] >= 'A') || (s[i] <= 'z' && s[i] >= 'a') || (s[i] <= '9' && s[i] >= '0'))
            res += table[toupper(s[i])];

    if (check(res))
        cout << "YES";
    else
        cout << "NO";

    return 0;
}
Editor is loading...