1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <algorithm> 5 #include <vector> 6 #include <map> 7 using namespace std; 8 9 #define GI ({int _t; scanf("%d", &_t); _t;}) 10 #define FOR(i, a, b) for (int i=a; i<b; i++) 11 #define REP(i, a) FOR(i, 0, a) 12 template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();} 13 int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;} 14 #define DBGV(_v) { REP(_i, _v.size()) { cout << _v[_i] << "\t";} cout << endl;} 15 map < char, char> lookup; 16 17 bool ispalindrome(string s) { 18 REP(i, s.size()/2+1) { 19 if (s[i] != s[s.size()-1-i]) return false; 20 } 21 return true; 22 } 23 24 bool ismirrored(string s) { 25 REP(i, s.size()/2+1) { 26 //cout << s[i] << "\t" << lookup[s[i]] << endl; 27 if (lookup[s[i]] != s[s.size()-1-i]) return false; 28 } 29 return true; 30 } 31 int main() { 32 33 //Insert all mappings 34 lookup['A'] = 'A'; 35 lookup['E'] = '3'; 36 lookup['H'] = 'H'; 37 lookup['I'] = 'I'; 38 lookup['J'] = 'L'; 39 lookup['L'] = 'J'; 40 lookup['M'] = 'M'; 41 lookup['O'] = 'O'; 42 lookup['S'] = '2'; 43 lookup['T'] = 'T'; 44 lookup['U'] = 'U'; 45 lookup['V'] = 'V'; 46 lookup['W'] = 'W'; 47 lookup['X'] = 'X'; 48 lookup['Y'] = 'Y'; 49 lookup['Z'] = '5'; 50 lookup['1'] = '1'; 51 lookup['2'] = 'S'; 52 lookup['3'] = 'E'; 53 lookup['5'] = 'Z'; 54 lookup['8'] = '8'; 55 56 string s; 57 while (cin >> s) { 58 bool pali = ispalindrome(s); 59 bool mirror = ismirrored(s); 60 if (pali == true && mirror == true) { 61 printf("%s -- is a mirrored palindrome.\n\n", s.c_str()); 62 } 63 else if (pali == true && mirror == false) { 64 printf("%s -- is a regular palindrome.\n\n", s.c_str()); 65 } 66 else if (pali == false && mirror == true) { 67 printf("%s -- is a mirrored string.\n\n", s.c_str()); 68 } 69 else if (pali == false && mirror == false) { 70 printf("%s -- is not a palindrome.\n\n", s.c_str()); 71 } 72 } 73 74 return 0; 75 76 }