#P106. [Sleeping Cup #4] Lottery Cheater
[Sleeping Cup #4] Lottery Cheater
Person in Charge
Attention
This problem requires file I/O (lottery.in / lottery.out).
In this problem, the indices of binary strings start from (leftmost bit). The input/output is given from the highest bit to the lowest bit.
Here is an example:
| Binary String | |
|---|---|
| Bit | |
| Bit | |
| Bit |
Problem Background
Unconsciously, it was already 7 PM—just one hour left until the lottery sales closed for the day.
Suddenly, the C-team coach mysteriously invited Sleeping Dolphin to buy a certain lottery ticket, claiming he had insider information. He admitted that he had made his fortune and became the C-team coach through lottery winnings.
"So this is why the C-team is in such a mess!" Sleeping Dolphin suppressed his anger and accompanied the C-team coach to buy the lottery.
Problem Description
The C-team coach told Sleeping Dolphin that a certain lottery uses the mt1.9937 algorithm for drawing numbers. The random number generation strategy of this algorithm is as follows:
- Read the current random seed ( is an -bit binary string).
- Define a new binary string , initially equal to .
- Repeat the following operation times: take the first bit of and append it to the end.
- The binary string is converted to a binary number, which serves as the generated random number.
Now, Sleeping Dolphin has reconstructed the binary string from the previous lottery results and asks you to further reconstruct the random seed .
Input Format
The first line contains two positive integers .
The second line contains a binary string of length .
Output Format
Output a binary string of length .
The data guarantees a solution, but there may be multiple answers. Output any valid one.
Samples
4 3
1100
1000
6 9
100100
100000
8 8
00000000
10000000
Sample 1 Explanation
According to the problem description, mt1.9937 generates the random number as follows:
- Read the current random seed ( is an -bit binary string).
- Define a new binary string , initially equal to .
- Repeat the following operation times: take the first bit of and append it to the end—
- 1st operation: $\tt{\color{red}1\color{black}000}\to\tt{\color{black}000\color{red}1}$.
- 2nd operation: $\tt{\color{red}0\color{black}001}\to\tt{\color{black}001\color{red}0}$.
- 3rd operation: $\tt{\color{red}0\color{black}010}\to\tt{\color{black}010\color{red}0}$.
- The binary string is converted to a binary number as the generated random number:
Thus, satisfies the requirement.
In fact, there are two correct answers for this sample. The other one is .