[SNCPC2019] Turn It Off

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

题目描述

It's already 21:30 now, and it's time for BaoBao to go to bed. To ensure his sleeping quality, BaoBao decides to turn all the lights in his bedroom off.

There are nn lights, numbered from 1 to nn, arranged in a row in BaoBao's bedroom. Each time BaoBao can select an integer ii and turn all the lights numbered from ii to (i+L1)(i+L-1) (both inclusive) off, where LL is a predefined positive integer. Note that each time the value of LL must be the same.

Given the initial status of all the lights, please help BaoBao determine the smallest possible LL so that he can turn all the lights off within kk times.

输入格式

There are multiple test cases. The first line of the input contains an integer TT, indicating the number of test cases. For each test case:

The first line contains two integers nn and kk (1kn2×1051 \le k \le n \le 2 \times 10^5).

The second line contains a string ss (s=n|s| = n, s{‘0’,‘1’}s \in \{\text{`0'}, \text{`1'}\}) indicating the initial status of the lights. Let sis_i be the ii-th character in ss, if si=‘1’s_i = \text{`1'} then the ii-th light is initially on, otherwise it's initially off. It's guaranteed that there is at least one `1· in ss.

It's guaranteed that the sum of nn of all test cases will not exceed 2×1062 \times 10^6.

输出格式

For each test case output one line containing one integer, indicating the smallest possible LL.

2
10 4
0101011111
3 1
010
3
1

2025-8 2025年CSP-J二分

未认领
状态
已结束
题目
25
开始时间
2025-8-9 0:00
截止时间
2025-8-24 23:59
可延期
24 小时