#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;
class Solution{
public:
bool reverse_strs(string& strs, unordered_set<char>& data)
{
if (strs.empty())
return true;
for (int i = 0; i < strs.size(); i++)
{
if (data.find(strs[i]) == data.end())
return false;
}
int left = 0;
int right = strs.size() - 1;
while (left < right)
{
if (strs[left] != strs[right])
return false;
++left;
--right;
}
return true;
}
};
int main()
{
string strs;
Solution solution;
unordered_set<char> data = { 'A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y' };
while (getline(cin, strs))
{
if (solution.reverse_strs(strs, data))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
system("pause");
return 0;
}
全部评论
(6) 回帖