1395: Binary Number
[命题人 : ]
题目描述
BLUE is learning binary numbers. There is an easy problem in his homework.
You are given a binary number s1∼n (s1 is the highest bit. sn is the lowest bit.). You need to do
an operation exactly k times: select an interval [l, r] (1 ≤ l ≤ r ≤ n) arbitrarily and flip sl , sl+1, ..., sr,
in other word, for all i ∈ [l, r], si becomes 1 if si is 0, si becomes 0 if si is 1. What is the biggest result
binary number after the k operations.
BLUE found useless algorithms useless on the problem, so he asked ACMZYX to help. ACMZYX looked down
on the problem but finally got WA (wrong answer). Can you help them to find the correct solution?
输入
The first line of the input contains a single integer T (1 ≤ T ≤ 6 × 104 ), indicating the number of
test cases
In each test case:
The first line contains two integers n, k. (1 ≤ n ≤ 105 , 0 ≤ k ≤ 1018)
The second line contains a binary number s1∼n. (s1 = 1, ∀i ∈ [2, n] : si ∈ {0, 1})
It’s guarenteed that in all test cases, ∑n ≤ 2.5 × 106
In each test case:
The first line contains two integers n, k. (1 ≤ n ≤ 105 , 0 ≤ k ≤ 1018)
The second line contains a binary number s1∼n. (s1 = 1, ∀i ∈ [2, n] : si ∈ {0, 1})
It’s guarenteed that in all test cases, ∑n ≤ 2.5 × 106
输出
You need to print a string of length n in one line, representing the biggest binary number after the k
operations.
样例输入 Copy
2
8 2
10100101
5 233333333333333333
11101
样例输出 Copy
11111101
11111