Problem:
Score : 100 points

Problem Statement

You are given a string S consisting of letters b, d, p and q.
Determine whether S is a mirror string.

Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S:

Reverse the order of the characters in S.

Replace each occurrence of b by d, d by b, p by q, and q by p, simultaneously.

Constraints

1 \leq |S| \leq 10^5

S consists of letters b, d, p, and q.

Input

The input is given from Standard Input in the following format:

S

Output

If S is a mirror string, print Yes. Otherwise, print No.

Sample Input 1

pdbq

Sample Output 1

Yes

Sample Input 2

ppqb

Sample Output 2

No

Solution in C++ (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
#include<stack>
using namespace std;
stack<char>s;//stack容器； 
string k;
int main()
{
    cin>>k;
    int lk=k.length();
    for(int i=0;i<lk;++i)
    s.push(k[i]);
    bool flag=1;
    for(int i=0;i<lk;++i)
    {
    	char top=s.top();
        if(top=='b') top='d';
        else if(top=='d') top='b';
        else if(top=='p') top='q';
        else if(top=='q') top='p';
		if(top==k[i]) 
		{
            flag=1;
            s.pop();
        }
        else 
        {
        	flag=0;
        	break;
        	
		}
	}
	if(flag==1)
	{

    	cout<<"YES"<<endl;
    	return 0;
	}
	if(flag==0)
    cout<<"NO";
    return 0;
}