P18160 [NWERC 2026] Involuted Interference

Description

Alice and Bob have built a DIY communication system with antennas and receiving dishes. They use their own *Novel Wondrous Exquisite Radio Communication* protocol to send messages. To demonstrate to the sceptical Carol how incredibly useful their creation is, they both intend to send her a message. At the start of every second, Alice and Bob can each either send a pulse representing a `1` bit or send nothing, representing a `0` bit. The receiving dish unfortunately cannot handle more than one pulse at the same time, so when Carol receives a pulse, she only knows that at least one of Alice or Bob sent a pulse, but not who or if both sent one. Additionally, all of them live in different time zones, and since time zones are too difficult to handle, Alice and Bob will just each pick a message, and then send this message on repeat. Carol will listen for $2026$ contiguous bits in a time frame where both Alice and Bob are sending their respective messages. Before Alice and Bob can demonstrate their wondrous creation to Carol, they need a program to reconstruct the original messages from this information. More formally, this problem consists of three passes. In the first pass, you receive a bitstring $a$, the message Alice has to transmit, and have to output a bitstring $s_a$, the sequence of bits she sends on repeat. In the second pass, you receive a bitstring $b$, the message Bob has to transmit, and have to output a bitstring $s_b$, the sequence of bits he sends on repeat. In the third and final pass the input is obtained in the following way. First, a substring $s_a'$ of length $2026$ is taken from $s_a + s_a + \cdots$, the infinite concatenation of $s_a$. A substring of a string $s$ is a contiguous sequence of characters of $s$. Then, a substring $s_b'$ of length $2026$ is taken from $s_b + s_b + \cdots$. The input bitstring $s := s_a' \mid s_b'$ is the bitwise OR of $s_a'$ and $s_b'$. You are given this bitstring $s$ and have to output the original bitstrings $a$ and $b$.

Input Format

The input consists of the following two lines. - One line with `Alice`, `Bob`, or `Carol`, representing pass $1$, $2$, and $3$ respectively. - One line depending on the pass. - **Pass 1**. A bitstring $a$ ($1 \leq |a| \leq 250$), the message Alice wants to transmit. - **Pass 2**. A bitstring $b$ ($1 \leq |b| \leq 250$), the message Bob wants to transmit. - **Pass 3**. A bitstring $s$ of length exactly $2026$. A bitstring is a string consisting of only `0` and `1`. The inputs of the first and second pass are determined before the first pass. The bitstring $s$ in the third pass might be chosen adaptively and adversarially depending on your outputs $s_a$ and $s_b$ from the first two passes. This is a multi-pass problem. Your program will be invoked three separate times per test case. Each test case is judged independently, without using information from other test cases. A testing tool is provided to help you develop your solution.

Output Format

- **Pass 1**. Output a bitstring $s_a$ ($1 \leq |s_a| \leq 2026$) that encodes $a$. - **Pass 2**. Output a bitstring $s_b$ ($1 \leq |s_b| \leq 2026$) that encodes $b$. - **Pass 3**. Output the two original bitstrings $a$ and $b$ in that order.

Explanation/Hint

### Samples #### Sample 1 **Pass 1** ##### Input ``` Alice 0101 ``` ##### Output ``` 01010101 ``` **Pass 2** ##### Input ``` Bob 000111 ``` ##### Output ``` 111000111000 ``` **Pass 3** ##### Input ``` Carol 111101111101111101111101... ``` ##### Output ``` 0101 000111 ``` ### Sample 1 Explanation In this sample, the output strings $s_a$ and $s_b$ from the first two passes are `01010101` and `111000111000`. When producing the input for the third pass, we have taken $s_a' = \mathtt{0101010101010101}\ldots$ and $s_b' = \mathtt{111000111000111000}\ldots$. Note that for example $s_a' = \mathtt{10101010}\ldots$ and/or $s_b' = \mathtt{1000111000111}\ldots$ would also have been valid. The input string $s$ for the third pass is then calculated as follows. $$ \begin{array}{rcl} s_a' &=& 0\;1\;0\;1\;0\;1\;0\;1\;0\;1\;0\;1\;0\;1\;0\;1\;0\;1\;0\;1\;0\;1\;0\;1\ldots\\ s_b' &=& 1\;1\;1\;0\;0\;0\;1\;1\;1\;0\;0\;0\;1\;1\;1\;0\;0\;0\;1\;1\;1\;0\;0\;0\ldots\\ \hline s = s_a' \mid s_b' &=& 1\;1\;1\;1\;0\;1\;1\;1\;1\;1\;0\;1\;1\;1\;1\;1\;0\;1\;1\;1\;1\;1\;0\;1\ldots \end{array} \quad (\text{bitwise OR}) $$ Its actual length is $2026$ and it keeps cycling through the above $24$ bits.