---
# System prepended metadata

title: UVa 401 - Palindromes

---

# UVa 401 - Palindromes

---
# 題目大意
給一字串，對每個字串輸出它是鏡像回文、一般回文、鏡像文還是什麼都不是。

---
# 題解
首先開一個map紀錄題目給的合法的鏡像文，再來開兩個變數，接著把字串掃一遍判斷條件就好了。


---

```=C++
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define INF 2147483647
#define ft first
#define sec second
#define pr pair<int,int>
#define ISCC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int t ,n ,m;
map<char ,char> mp;
string s;
int main() 
{
	ISCC;
	mp['A']='A'; mp['E']='3'; mp['H']='H';
	mp['I']='I'; mp['J']='L'; mp['L']='J';
	mp['M']='M'; mp['O']='O'; mp['S']='2';
	mp['T']='T'; mp['U']='U'; mp['V']='V';
	mp['W']='W'; mp['X']='X'; mp['Y']='Y';
	mp['Z']='5'; mp['1']='1'; mp['2']='S';
	mp['3']='E'; mp['5']='Z'; mp['8']='8';
	while(getline(cin,s))
	{
		int pok=1 ,mok=1 ,len=s.size();
		for(int i=0 ;i<(len+1)/2 ;i++) 
		{
			if(s[i]==s[len-1-i] || (mp.count(s[i]) && s[len-1-i]==mp[s[i]]))	
			{
				if(!(mp.count(s[i]) && s[len-1-i]==mp[s[i]])) mok = 0;
				if(s[i] != s[len-1-i]) pok = 0;
			}											
			else 
			{
				mok = pok = 0;
				break;
			}
		}
		cout << s;
		if(pok && mok) cout << " -- is a mirrored palindrome.\n";
		else if(pok) cout << " -- is a regular palindrome.\n";
		else if(mok) cout << " -- is a mirrored string.\n";
		else cout << " -- is not a palindrome.\n";
		cout << '\n';
	}
}
```

