#P8763. [蓝桥杯 2021 国 ABC] 异或变换

[蓝桥杯 2021 国 ABC] 异或变换

Problem Description

Xiao Lan has a binary string s=s1s2s3sns=s_{1} s_{2} s_{3} \cdots s_{n}.

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 s=s1s2s3sns=s_{1} s_{2} s_{3} \cdots s_{n}, 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 aba \oplus b denotes the bitwise XOR of two bits. When aa and bb are the same, the result is 00; when aa and bb are different, the result is 11.

What is the binary string after tt transformations?

Input Format

The first line contains two integers n,tn, t, representing the length of the binary string and the number of transformations.

The second line contains a binary string of length nn.

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 40%40\% of the testdata, 1n1001 \leq n \leq 100 and 1t10001 \leq t \leq 1000.

For 80%80\% of the testdata, 1n10001 \leq n \leq 1000 and 1t1091 \leq t \leq 10^{9}.

For all testdata, 1n100001 \leq n \leq 10000 and 1t10181 \leq t \leq 10^{18}.

Lanqiao Cup 2021 National Contest, Group A Problem F (Group B Problem G, Group C Problem G).

Translated by ChatGPT 5