D. Secret Messages

Codeforces
IDCF10238D
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
On Planet E, people share messages secretly! In order not to allow others to read their messages easily, they encode their messages before sending, and decode the received texts to get back the message. To make things simpler, they decide to make the encoding method and decoding method the same! They have thought of three different methods. The first is to swap the lower case and upper case characters. For example, *Hello* would become *hELLO* using this encoding. The second is to reverse the word. For example, *Hello* would become *olleH* using this encoding. The third is to use the ROT13 (rotate 13) encoding. In this method, each character would be moved to the 13-th character after it, with *A* being the next character of *Z* (and *a* being the next character of *z*). The case remains unchanged. Since there are 26 English characters, applying ROT13 twice would give back the original word. For example, *Hello* would become *Uryyb* using this encoding. Since all three methods look nice and the people on Planet E do not want to give up any of them. Hence they decide to use all three encodings together! Can you help the people on Planet E to do the encoding? The first line contains a positive integer $T$ ($T <= 100$), the number of testcases. Each testcase contains a string $s$ with at least $1$ character and at most $100$ characters. Each of characters is either a lower case English character or an upper case English character. For each testcase, output a single line consisting of the encoded string. ## Input The first line contains a positive integer $T$ ($T <= 100$), the number of testcases.Each testcase contains a string $s$ with at least $1$ character and at most $100$ characters. Each of characters is either a lower case English character or an upper case English character. ## Output For each testcase, output a single line consisting of the encoded string. [samples]
**Definitions** Let $ T \in \mathbb{Z}^+ $ be the number of test cases. For each test case $ k \in \{1, \dots, T\} $, let $ s_k $ be a string of length $ n_k \in [1, 100] $, where each character is in $ A \cup a $, with $ A = \{A, B, \dots, Z\} $, $ a = \{a, b, \dots, z\} $. **Encoding Function** For each string $ s_k $, apply the following three operations in sequence: 1. **Case Swap**: For each character $ c \in s_k $, $$ c \mapsto \begin{cases} \text{lower}(c) & \text{if } c \in A \\ \text{upper}(c) & \text{if } c \in a \end{cases} $$ 2. **Reverse**: Reverse the entire string. 3. **ROT13**: For each character $ c $ in the resulting string, $$ c \mapsto \begin{cases} \text{chr}((\text{ord}(c) - \text{ord}('A') + 13) \bmod 26 + \text{ord}('A')) & \text{if } c \in A \\ \text{chr}((\text{ord}(c) - \text{ord}('a') + 13) \bmod 26 + \text{ord}('a')) & \text{if } c \in a \end{cases} $$ **Constraints** 1. $ 1 \le T \le 100 $ 2. For each $ k $, $ 1 \le |s_k| \le 100 $, and $ s_k \in (A \cup a)^* $ **Objective** For each test case $ k $, output the string obtained by applying the above three encoding steps in order to $ s_k $.
API Response (JSON)
{
  "problem": {
    "name": "D. Secret Messages",
    "description": {
      "content": "On Planet E, people share messages secretly! In order not to allow others to read their messages easily, they encode their messages before sending, and decode the received texts to get back the messa",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10238D"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "On Planet E, people share messages secretly!\n\nIn order not to allow others to read their messages easily, they encode their messages before sending, and decode the received texts to get back the messa...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z}^+ $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $, let $ s_k $ be a string of length $ n_k \\in [1, 100] $, where each character i...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments