AtCoder Regular Contest 150
A
Continuous 1
AtCoder
⌀ 952
原题
←B →
翻译中…

Problem Statement

翻译中…

You are given a string of length $N$, $S=S_1S_2\dots S_N$, consisting of 0, 1, and ?.

翻译中…

We like to replace every ? with 0 or 1 so that all of the following conditions are satisfied.

翻译中…
  • $S$ contains exactly $K$ occurrences of 1.
  • These $K$ occurrences of 1 are consecutive. That is, there is an $i\ (1 \leq i \le N-K+1)$ such that $S_i=S_{i+1}=\dots=S_{i+K-1}=$ 1.
翻译中…

Determine whether there is exactly one way to replace the characters to satisfy the conditions.

翻译中…

You have $T$ test cases to solve.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 10^5$
  • $1 \leq K < N \leq 3 \times 10^5$
  • $S$ is a string of length $N$ consisting of 0, 1, and ?.
  • The sum of $N$ across the test cases is at most $3 \times 10^5$.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

T
\mathrm{case}_1
\vdots
\mathrm{case}_T

翻译中…

Each case is in the following format:

翻译中…

N K
S

翻译中…

Output

翻译中…

Print $T$ lines. The $i$-th line should contain Yes if, for the $i$-th test case, there is exactly one way to replace the characters to satisfy the conditions, and No otherwise.

翻译中…

样例

Input #1
4
3 2
1??
4 2
?1?0
6 3
011?1?
10 5
00?1???10?
Output #1
Yes
No
No
Yes
For the first test case, turning $S$ into `101`, for instance, does not satisfy the conditions since the `1`s will not be consecutive. The only way to satisfy the conditions is to turn $S$ into `110`. For the second test case, we may turn $S$ into `1100` or `0110` to satisfy the conditions, so there are two ways to satisfy them. For the third test case, there is no way to replace the characters to satisfy the conditions.
题目信息
题号
arc150_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。