CF2154A.Notelock

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

Notelock

Teto is playing the hit rhythm game osu!. The game can be described by a binary string^{\text{∗}} ss of length nn and a positive integer kk where the following will happen in order:

  • You will choose some positions in ss to protect.
  • Then for each ii (1in1 \le i \le n) in increasing order, Teto can set sis_i to 0 if all the following are true:
    • si=1s_i = \mathtt{1},
    • sis_i is not protected,
    • the previous k1k - 1 elements do not contain 1. More formally, 1 does not occur in smax(1,ik+1),,si1s_{\max(1, i - k + 1)},\ldots,s_{i - 1}.

You dislike Teto (for some reason). So determine the minimum number of positions you need to protect to force her to leave ss unchanged.

^{\text{∗}}A binary string is a string that only consists of characters 0 and 1.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1001 \le t \le 100). The description of the test cases follows.

The first line of each testcase contains integers nn and kk (2n10002 \le n \le 1000; 2kn2 \le k \le n) — the length of ss and kk.

The second line of each test case contains a binary string ss of length nn consisting of characters 0 and 1.

The sum of nn across all testcases does not exceed 10001000.

Output

For each testcase, output the minimum number of positions you need to protect to force Teto to leave the string unchanged.

Note

For the first testcase, you can protect the first element and have: s=11s = \mathtt{\color{red}{1}1}. Now Teto cannot change s1s_1 because it is protected and cannot change s2s_2 because s1=1s_1 = \mathtt{1}. It can be proven this is optimal.

For the second testcase, you can protect only the first element and have s=100001s = \color{red}{\mathtt{1}}\mathtt{00001}. Teto cannot change s1s_1 because it is protected and she cannot change s6s_6 because there is 1 in the previous k1k - 1 elements (100001\color{blue}{\mathtt{10000}}\mathtt{1}).

For the fourth testcase, you must protect s1,s3,s5,s7s_1,s_3,s_5,s_7 and have $s = \mathtt{\color{red}{1}0\color{red}{1}0\color{red}{1}0\color{red}{1}}$. It can be shown that this is optimal. For example, if you did not protect s3s_3, then Teto can change it to 0 (\color{red}{1}\color{blue}{0}10\color{red}{1}0\color{red}{1})

Samples

9
2 2
11
6 6
100001
5 3
10000
7 2
1010101
7 4
0000001
3 3
010
3 2
011
7 4
1001001
8 3
00000000
1
1
1
4
1
1
1
1
0

在线编程 IDE

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