CF2136B Like the Bitset
Description
You are given a binary string$$$^{\\text{∗}}$$$ $$$s$$$ of length $$$n$$$, as well as an integer $$$k$$$.
Aquawave wants to construct a permutation$$$^{\\text{†}}$$$ $$$p$$$ of length $$$n$$$, so that for each $$$1\\le i\\le n$$$, where $$$s\_i=\\mathtt{1}$$$, the following holds:
- For each interval $$$\[l, r\]$$$ ($$$1\\le l\\le r\\le n$$$) whose length is at least $$$k$$$ (i.e. $$$r - l + 1 \\geq k$$$), if it covers position $$$i$$$ (i.e. $$$l \\leq i \\leq r$$$), then the maximum element among $$$p\_l, p\_{l+1}, \\ldots, p\_r$$$ is not $$$p\_i$$$.
Note that there are no such constraints on indices with $$$s\_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 $$$\\mathtt{0}$$$ or $$$\\mathtt{1}$$$.
$$$^{\\text{†}}$$$A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$\[2,3,1,5,4\]$$$ is a permutation, but $$$\[1,2,2\]$$$ is not a permutation ($$$2$$$ appears twice in the array), and $$$\[1,3,4\]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).
Input Format
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\leq n \\leq 2 \\cdot 10^5$$$, $$$1 \\leq k \\leq n$$$) — the length of $$$s$$$ and the integer in the statements.
The second line contains the binary string $$$s$$$ of length $$$n$$$ ($$$s\_i = \\mathtt{0}$$$ or $$$\\mathtt{1}$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.
Output Format
For each test case:
- If there is at least one possible permutation:
- Print "YES" in the first line of output;
- Then, print $$$n$$$ integers $$$p\_1, p\_2, \\ldots, p\_n$$$ ($$$1 \\leq p\_i \\leq n$$$, all $$$p\_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.
Explanation/Hint
In the first test case, you can output an arbitrary permutation of length $$$n = 2$$$, since all $$$s\_i$$$-s are equal to $$$\\mathtt{0}$$$.
In the second test case, $$$p=\[1, 4, 3, 2\]$$$ is a valid answer because:
- The only position where $$$s\_i = \\tt{1}$$$ is $$$i = 3$$$. There are three distinct intervals $$$\[l, r\]$$$ covering index $$$3$$$, whose length is at least $$$k=3$$$: $$$\[1, 3\]$$$, $$$\[1, 4\]$$$, and $$$\[2, 4\]$$$;
- And, for each of the three intervals, the maximum element among $$$p\_l, \\ldots, p\_r$$$ should be $$$p\_2 = 4$$$, which is not equal to $$$p\_3 = 3$$$.