This is a two-step problem.
Dadas wants to send Lunarlity a binary string of length . A binary string contains only the characters 0 and 1.
Exactly one bit is flipped during transmission: a 0 becomes 1, or a 1 becomes 0. Neither participant knows which position will be flipped, and Lunarlity is not told that position.
They may agree on an encoding and decoding strategy in advance. Dadas encodes the original string as a binary string of length from to . Lunarlity receives only that string with one bit flipped and must recover the original exactly. The strategy must succeed for every original string and every possible flipped position.
Your program is executed twice for each test datum. In the first execution it acts as Dadas and encodes the data; in the second it acts as Lunarlity and decodes the data. Each execution starts in a fresh process. Variables and files from the first execution are not carried over; the only transmitted information is the corrupted string.
Both executions use the same submitted code. Print the required result and terminate in each execution. The recovered string in the second execution must equal the original string supplied in the first.
The input has one of the following two formats. The first line gives the role , and the second line gives a string.
First execution:
dadas
is the original binary string of length that Dadas wants to send.
Second execution:
lunarlity
If the role is dadas, print the encoded binary string on the first line. Its length must be from to .
If the role is lunarlity, print the recovered binary string of length on the first line. It must equal from the first execution exactly.
Print only one string in each execution. Invalid output or an incorrect recovered string is judged wrong.
is the string printed in the first execution for the same test datum, with exactly one bit flipped. Its length is unchanged.