QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100 Interactive

#18516. Game: Binary String

Statistics

This is an interactive problem.

Alice and Bob are playing a game with a binary string $s$ and a fixed integer $k$. Initially, there is an empty string $t$. The players take turns appending a character ('0' or '1') to the end of $t$, starting with Alice.

The interaction always continues until exactly $k$ characters have been appended to $t$. Alice wins if and only if the final string $t$ contains $s$ as a contiguous substring. Otherwise, Bob wins.

You may choose to play as either Alice or Bob. Your goal is to win the game against the jury.

Interaction

Each test run contains multiple test cases. You should first read a line with an integer $T$ ($1 \le T \le 100$), representing the number of test cases.

For each test case, you begin the interaction by reading a binary string $s$ and an integer $k$ in a single line ($1 \le |s| \le k \le 100$), denoting the number of rounds and parameters of the game. Afterwards, output one word: Alice if you choose to play as Alice, or Bob if you choose to play as Bob. After that, the game starts from the empty string. Alice makes the first move. Whenever it is your turn, output one character, either 0 or 1. Whenever it is the jury's turn, read one character, either 0 or 1. The game ends when the current string has length $k$.

After every output operation you must flush the output buffer. For example, in C++ you may use cout << endl; or cout.flush();.

If you output an invalid token, make a move after the game has ended, fail to flush, or lose the game, you will receive Wrong Answer.

Note

The following table shows a possible interaction for the sample. Lines in the "Jury" column are read by the contestant's program, and lines in the "Contestant" column are printed by the contestant's program.

Jury Contestant Explanation
1 There is one test case.
01 3 $s=\texttt{01}$ and $k=3$.
Alice The contestant chooses to play as Alice.
0 Alice appends 0, so $t=\texttt{0}$.
0 Bob appends 0, so $t=\texttt{00}$.
1 Alice appends 1, so $t=\texttt{001}$. Alice wins because $t$ contains 01.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.