B - Mirror String Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 100

問題文

b, d, p, q4 種類の文字から構成される文字列 S が与えられます。 S が「鏡文」かどうかを判定してください。

ここで、「鏡文」というのは以下の操作を文字列 S に施したときに、元と同じ文字列が得られるような文字列 S のことです。

  1. S の順序を逆転する。

  2. bd に、db に、pq に、qp に置換する。

制約

  • 1 \leq |S| \leq 10^5
  • Sb, d, p, q4 種類の文字のみから構成される。

入力

入力は以下の形式で標準入力から与えられる。

S

出力

S が「鏡文」ならば Yes を、そうでないならば No を出力せよ。


入力例 1

pdbq

出力例 1

Yes

入力例 2

ppqb

出力例 2

No

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:

  1. Reverse the order of the characters in S.

  2. 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