

Time Limit: 2 sec / Memory Limit: 2048 MB
配点 : 点
問題文
個の、長さ の 文字列 が与えられます。 の 文字目を と表します。ここで、1
を満たす整数組 が少なくとも一つ存在することが制約より保証されています。
高橋君と青木君が以下のようなゲームを行います。
- 高橋君が
1
を満たす整数組 を つ選ぶ。 - 回以上 回以下、青木君が高橋君に質問を行う。各質問では青木君が を満たす整数組 を選び、「 と のうち少なくとも一方が成り立つ」の真偽を高橋君から教えてもらう。
- 青木君が を予想する。予想が当たっていれば青木君の勝ち、そうでなければ負けとなる。
青木君は高橋君が選ぶ の候補、すなわち を知った状態でゲームを行います。また、上記2では以前の質問に対する返事を聞いたうえで を選ぶことができます。
青木君が適切な戦略を取った場合、高橋君の の選び方や運によらず必ずゲームに勝てるかどうかを判定してください。
つの入力につきテストケースは 個あります。
制約
- つの入力の中のテストケースすべてにわたる の総和は 以下である
- は長さ の 文字列
-
1
を満たす整数組 が少なくとも一つ存在する
入力
入力は以下の形式で標準入力から与えられる。
各テストケースは以下の形式で与えられる。
出力
各テストケースに対し、青木君が必ずゲームに勝てるならば Yes
と、そうでなければ No
と出力せよ。
入力例 1Copy
3 2 01 11 2 11 11 10 0101011110 1100100001 1101100000 0111101010 1000011001 1110101010 1110110100 1110000110 0000001011 1001111100
出力例 1Copy
Yes No Yes
番目のテストケースに対するゲームの一例を以下に示します。
- 高橋君が
1
を満たす として を選ぶ。 - 青木君が 回質問を行う。 回目の質問では として、高橋君から「 と のうち少なくとも一方が成り立つ」が偽であると教えてもらう。 回目の質問では として、高橋君から「 と の少なくとも一方が成り立つ」が真であると教えてもらう。
- 青木君が と予想する。この予想は当たっているため、青木君の勝ちである。
これはあくまでゲームの一例であり、青木君の戦略が適切とは限りません。しかし、青木君が適切な戦略を取った場合には必ず青木君がゲームに勝つため、 番目のテストケースに対する出力は Yes
になります。
Score : points
Problem Statement
You are given strings , each of length , consisting only of 0
and 1
. Let denote the -th character of . It is guaranteed by the constraints that there exists at least one integer pair satisfying 1
.
Takahashi and Aoki play the following game:
- Takahashi chooses one integer pair satisfying and
1
. - Aoki asks Takahashi at least and at most questions. In each question, Aoki chooses an integer pair satisfying , and Takahashi tells Aoki whether "At least one of or holds" is true or false.
- Aoki guesses . If his guess is correct, Aoki wins; otherwise, he loses.
Aoki knows the possible choices of that Takahashi can choose, that is, he knows before playing the game. Also, in step 2, Aoki can choose based on the answers to previous questions.
Determine whether Aoki can always win the game regardless of Takahashi's choice of and randomness, if he uses an appropriate strategy.
There are test cases in each input.
Constraints
- The sum of over all test cases in each input is at most .
- is a string of length consisting of
0
and1
. - There is at least one integer pair satisfying
1
.
Input
The input is given from Standard Input in the following format:
Each test case is given in the following format:
Output
For each test case, print Yes
if Aoki can always win the game, and No
otherwise.
Sample Input 1Copy
3 2 01 11 2 11 11 10 0101011110 1100100001 1101100000 0111101010 1000011001 1110101010 1110110100 1110000110 0000001011 1001111100
Sample Output 1Copy
Yes No Yes
In the first test case, an example of the game is as follows:
- Takahashi chooses satisfying
1
. - Aoki asks two questions. In the first question, he chooses . Takahashi tells him that "At least one of or holds" is false. In the second question, he chooses . Takahashi tells him that "At least one of or holds" is true.
- Aoki guesses . Since his guess is correct, Aoki wins.
This is just an example of the game, and Aoki's strategy might not be optimal. However, if Aoki uses an appropriate strategy, he can always win the game, so the output for the first test case is Yes
.