Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 100 点
問題文
b
, d
, p
, q
の 4 種類の文字から構成される文字列 S が与えられます。
S が「鏡文」かどうかを判定してください。
ここで、「鏡文」というのは以下の操作を文字列 S に施したときに、元と同じ文字列が得られるような文字列 S のことです。
-
S の順序を逆転する。
-
b
をd
に、d
をb
に、p
をq
に、q
をp
に置換する。
制約
- 1 \leq |S| \leq 10^5
- S は
b
,d
,p
,q
の 4 種類の文字のみから構成される。
入力
入力は以下の形式で標準入力から与えられる。
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:
-
Reverse the order of the characters in S.
-
Replace each occurrence of
b
byd
,d
byb
,p
byq
, andq
byp
, simultaneously.
Constraints
- 1 \leq |S| \leq 10^5
- S consists of letters
b
,d
,p
, andq
.
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