Mirror String

AtCoder
IDrelay_b
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
Input #1
pdbq
Output #1
Yes
Input #2
ppqb
Output #2
No
API Response (JSON)
{
  "problem": {
    "name": "Mirror String",
    "description": {
      "content": "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",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "relay_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a string $S$ consisting of letters `b`, `d`, `p` and `q`. Determine whether $S$ is a _mirror string_.\nHere, a mirror string is a string $S$ such that the following sequence of operations...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments