QOJ.ac

QOJ

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

#18516. 遊戲:二進制字符串

Statistics

這是一個互動題。

Alice 和 Bob 用一個二進位字串 $s$ 和一個固定整數 $k$ 來玩遊戲。一開始,有一個空字串 $t$。玩家輪流在 $t$ 的結尾加入一個字元('0' 或 '1'),由 Alice 先手。

互動會持續進行,直到 $t$ 恰好被加入 $k$ 個字元為止。若且唯若最終的字串 $t$ 包含 $s$ 作為連續子字串時,Alice 獲勝;否則 Bob 獲勝。

你可以選擇扮演 Alice 或 Bob。你的目標是擊敗評審。

互動

每次測試執行包含多個測試案例。你應該先讀取一行,包含一個整數 $T$($1 \le T \le 100$),代表測試案例的數量。

對於每個測試案例,你在一行中讀取一個二進位字串 $s$ 和一個整數 $k$($1 \le |s| \le k \le 100$),表示遊戲的回合數與參數。 接著,輸出一個單詞:如果你選擇扮演 Alice 則輸出 Alice,若選擇扮演 Bob 則輸出 Bob。 之後,遊戲從空字串開始。Alice 進行第一步。每當輪到你的回合時,輸出一個字元,01。每當輪到評審的回合時,讀取一個字元,01遊戲在當前字串長度達到 $k$ 時結束。

每次輸出後你必須刷新輸出緩衝區。例如,在 C++ 中你可以使用 cout << endl;cout.flush();

如果你輸出了無效的記號、在遊戲結束後操作、未能刷新緩衝區、或輸掉遊戲,你將得到 Wrong Answer。

範例

輸入格式 1

1
01 3
0

輸出格式 1

Alice
0
1

說明

$s=\texttt{01}$ 且 $k=3$。參賽者選擇扮演 Alice。Alice 先加入 0,字串變成 $\texttt{0}$。Bob 加入 0,字串變成 $\texttt{00}$。最後 Alice 加入 1,字串變成 $\texttt{001}$,包含 01,Alice 獲勝。

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.