#P8763. [蓝桥杯 2021 国 ABC] 异或变换
[蓝桥杯 2021 国 ABC] 异或变换
Problem Description
Xiao Lan has a binary string .
After that, at each moment, Xiao Lan will apply a transformation to this binary string. The rule of each transformation is the same. For the binary string , the transformed binary string $s^{\prime}=s_{1}^{\prime} s_{2}^{\prime} s_{3}^{\prime} \cdots s_{n}^{\prime}$ is:
$$\begin{aligned} &s_{1}^{\prime}=s_{1} \\ &s_{i}^{\prime}=s_{i-1} \oplus s_{i} \end{aligned}$$Here denotes the bitwise XOR of two bits. When and are the same, the result is ; when and are different, the result is .
What is the binary string after transformations?
Input Format
The first line contains two integers , representing the length of the binary string and the number of transformations.
The second line contains a binary string of length .
Output Format
Output one line containing a binary string, which is the transformed string.
5 3
10110
11010
Hint
Sample Explanation
Initially it is 10110. After 1 transformation it becomes 11101, after 2 transformations it becomes 10011, and after 3 transformations it becomes 11010.
Constraints
For of the testdata, and .
For of the testdata, and .
For all testdata, and .
Lanqiao Cup 2021 National Contest, Group A Problem F (Group B Problem G, Group C Problem G).
Translated by ChatGPT 5