Chat, we've done it! We've made a computer... in Minecraft! The only thing is, it has a peculiar instruction set called RSC-IV, or "Redstone Computer 4". "Redstone Computer" because the logic is built with redstone, and "4" because there are only 4 values that it understands.
Because it only understands 4 values, RSC-IV only has 4 instructions that a program can contain. A program is just a 1-dimensional line of wood blocks. The only valid wood blocks are Acacia, Birch, Cherry, and Dark Oak. From here on out, we will just refer to these blocks by their first letters: A, B, C, and D.
RSC-IV has only four components.
Each block in the program is one instruction that either acts on the register, the instruction pointer, or the output. Here are the effects of the 4 program blocks:
| Block | Instruction | Effect |
| A | INC | Add 1 to the value in the register, then increment the instruction pointer |
| B | DUB | Double the value in the register, then increment the instruction pointer |
| C | JMP | Increase the instruction pointer by $$$R$$$, where $$$R$$$ is the value in the register |
| D | PUT | Put/append the value in the register into the output as a block, where 0=A, 1=B, 2=C, and 3=D, then increment the instruction pointer |
There are three caveats to note:
One fun thing computer scientists like to do is make a "quine" – a program that outputs itself. We won't have you make a quine, but we'll ask for something similar. The challenge we have for you is the following: take a given output string $$$S$$$ and make a valid RSC-IV program $$$P$$$ with the following constraints:
The first and only line contains an output string $$$S$$$ $$$(1 \le |S| \le 100)$$$ consisting only of $$$A$$$s, $$$B$$$s, $$$C$$$s, and $$$D$$$s.
Print a program string $$$P$$$ $$$(|P| \le 1000)$$$ which will print exactly $$$S$$$ and contains $$$S$$$ as a substring. Print "C" if the task is impossible.
AAAA
AAAABBBBDDDDC
ABCDA
ABCDABBBBDADBBAADBAAADADC
DADADADADA
C
| Название |
|---|


