CF2136B.Like the Bitset

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Like the Bitset

You are given a binary string^{\text{∗}} ss of length nn, as well as an integer kk.

Aquawave wants to construct a permutation^{\text{†}} pp of length nn, so that for each 1in1\le i\le n, where si=1s_i=\mathtt{1}, the following holds:

  • For each interval [l,r][l, r] (1lrn1\le l\le r\le n) whose length is at least kk (i.e. rl+1kr - l + 1 \geq k), if it covers position ii (i.e. lirl \leq i \leq r), then the maximum element among pl,pl+1,,prp_l, p_{l+1}, \ldots, p_r is not pip_i.

Note that there are no such constraints on indices with si=0s_i = \mathtt{0}.

You have to find such a permutation, or determine that such permutations do not exist.

^{\text{∗}}A binary string is a string where each character is either 0 or 1.

^{\text{†}}A permutation of length nn is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array), and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array).

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains two integers nn and kk (1n21051 \leq n \leq 2 \cdot 10^5, 1kn1 \leq k \leq n) — the length of ss and the integer in the statements.

The second line contains the binary string ss of length nn (si=0s_i = \mathtt{0} or 1).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case:

  • If there is at least one possible permutation:
    • Print "YES" in the first line of output;
    • Then, print nn integers p1,p2,,pnp_1, p_2, \ldots, p_n (1pin1 \leq p_i \leq n, all pip_i-s are distinct) in the second line — the permutation you constructed.
  • Otherwise, print "NO" in the single line of output.

You can output the tokens in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

If there are multiple answers, you may output any of them.

Note

In the first test case, you can output an arbitrary permutation of length n=2n = 2, since all sis_i-s are equal to 0.

In the second test case, p=[1,4,3,2]p=[1, 4, 3, 2] is a valid answer because:

  • The only position where si=1s_i = \tt{1} is i=3i = 3. There are three distinct intervals [l,r][l, r] covering index 33, whose length is at least k=3k=3: [1,3][1, 3], [1,4][1, 4], and [2,4][2, 4];
  • And, for each of the three intervals, the maximum element among pl,,prp_l, \ldots, p_r should be p2=4p_2 = 4, which is not equal to p3=3p_3 = 3.

Samples

6
2 1
00
4 3
0010
5 2
11011
7 5
1111110
8 4
00101011
10 2
1000000010
YES
1 2
YES
1 4 3 2
NO
NO
YES
6 5 2 3 4 8 1 7
YES
1 2 3 4 5 6 7 9 8 10

在线编程 IDE

建议全屏模式获得最佳体验