A. Abnormal Words

Codeforces
IDCF10236A
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
"_Khoor!_" David exclaimed to Aram. "_Jreeohghbjrrn!_" Aram responded. Dismayed to find that club members weren't sufficiently confused, Aram and David decided to speak in a new language. Rather invent one from scratch, they decided to encode their speech with a Caesar cipher. Specifically, they agree on the _Caesar shift_ $s$. To say a word, they replace each of its letters by the letter that comes $s$ places later in the alphabet. Letters that pass _z_ wrap back around to _a_. For example if $s = 4$, _a_ becomes _e_, _b_ becomes _f_, and _y_ becomes _c_. Encoding and decoding words in their heads is very slow, so David and Aram asked you to write a program to automate this process. After all, they're still untangling their tongues after saying _jreeohghbjrrn_! The first line contains a single character, either "_E_" or "_D_", indicating whether Aram and David are requesting a word to encode or decode, respectively. The second line contains a integer $s$ ($1 <= s <= 25$), the shift. The third line contains a single word $w$ ($1 <= | w | <= 100$) consisting solely of the lowercase Latin letters from _a_ to _z_. On a single line output the encrypted or decrypted word, as requested. ## Input The first line contains a single character, either "_E_" or "_D_", indicating whether Aram and David are requesting a word to encode or decode, respectively.The second line contains a integer $s$ ($1 <= s <= 25$), the shift.The third line contains a single word $w$ ($1 <= | w | <= 100$) consisting solely of the lowercase Latin letters from _a_ to _z_. ## Output On a single line output the encrypted or decrypted word, as requested. [samples]
**Definitions** Let $ A, B, C \in \mathbb{Z}^+ $ with $ 1 \leq A, B, C \leq 1000 $. Let $ K \in \mathbb{Z}^+ $ be the number of cake pieces, with $ K \leq 5000 $. For each piece $ i \in \{1, \dots, K\} $, define: - $ w_i \in \mathbb{R}^+ $: weight of piece $ i $, - $ a_i \in \{1, \dots, A\} $: recipient index if $ A $ guests arrive, - $ b_i \in \{1, \dots, B\} $: recipient index if $ B $ guests arrive, - $ c_i \in \{1, \dots, C\} $: recipient index if $ C $ guests arrive. **Constraints** 1. $ \sum_{i=1}^K w_i \leq 10^{18} $ 2. For each $ i \in \{1, \dots, K\} $: - $ w_i > 0 $, - $ 1 \leq a_i \leq A $, - $ 1 \leq b_i \leq B $, - $ 1 \leq c_i \leq C $. 3. $ K \leq 5000 $ **Objective** Partition the cake into $ K $ pieces such that: - When $ A $ guests arrive, the pieces can be partitioned into $ A $ groups (one per guest) with equal total weight. - When $ B $ guests arrive, the pieces can be partitioned into $ B $ groups with equal total weight. - When $ C $ guests arrive, the pieces can be partitioned into $ C $ groups with equal total weight. That is, for each $ x \in \{A, B, C\} $, the multiset $ \{w_i\} $ can be partitioned into $ x $ subsets, each summing to $ \frac{W}{x} $, where $ W = \sum_{i=1}^K w_i $.
API Response (JSON)
{
  "problem": {
    "name": "A. Abnormal Words",
    "description": {
      "content": "\"_Khoor!_\" David exclaimed to Aram. \"_Jreeohghbjrrn!_\" Aram responded. Dismayed to find that club members weren't sufficiently confused, Aram and David decided to speak in a new language. Rather inv",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10236A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "\"_Khoor!_\" David exclaimed to Aram.\n\n\"_Jreeohghbjrrn!_\" Aram responded.\n\nDismayed to find that club members weren't sufficiently confused, Aram and David decided to speak in a new language. Rather inv...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ A, B, C \\in \\mathbb{Z}^+ $ with $ 1 \\leq A, B, C \\leq 1000 $.  \nLet $ K \\in \\mathbb{Z}^+ $ be the number of cake pieces, with $ K \\leq 5000 $.  \nFor each piece $ i \\in \\{1, \\do...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments