問題一覧 > 通常問題

No.2814 Block Game

レベル : / AI推定難易度 : 2100 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 29
作問者 : Yoyoyo8128 / テスター : hirayuu_yc Magentor warabi0906 highlighter fact493 zeta7532
お気に入りにしたユーザー ProblemId : 11080 / 自分の提出
問題文最終更新日: 2024-07-19 21:19:38
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 437 ('09 Contest 002 day2) (順位表) の他の問題:

Problem Statement

Alice and Bob are playing a game using a sequence $A$ of length $N$. Initially, $A_i=-1$ for every $i$ such that $1\leq i\leq N$.

Starting with Alice, Alice and Bob alternately perform the following series of steps.

  • If there is no $i$ such that $A_i=-1$, end the game.
  • If there is one, first choose an integer $x$ between $1$ and $N$, inclusive, and one $i$ such that $A_i=-1$. Here, $x$ must not be contained in $A$.
  • Then, replace $A_i$ with $x$.

After the game has ended, the following operation is performed on the sequence $A$ at most $N-1$ times.

  • Let $n$ be the length of $A$ at the start of the operation. Replace $A$ with $(A_1+A_2,A_2+A_3,\dots,A_{n-1}+A_{n})$.

It can be shown that in the end exactly one integer remains in $A$. Let that integer be $X$.

The outcome of this game is determined as follows, using a string $S$ that is either Odd or Even.

  • When $S$ is Odd: if $X$ is odd, Alice wins; if it is even, Bob wins.
  • When $S$ is Even: if $X$ is even, Alice wins; if it is odd, Bob wins.

When both players act optimally to win, which of Alice and Bob wins?

You are given $T$ test cases; answer each of them.

Constraints

  • $1\leq T\leq 2\times 10^{5}$
  • $1\leq N\leq 10^{18}$
  • $S$ is Odd or Even
  • $T,N$ are integers

Input

$T$
$\text{testcase}_1$
$\text{testcase}_2$
$\vdots$
$\text{testcase}_T$

Each test case is given in the following format.

$N$ $S$

Output

Output $T$ lines.

On the $i$-th line, for the $i$-th test case, output Alice if Alice wins, and Bob if Bob wins.

Sample

Sample 1
Input
1
3 Even
Output
Alice

In this sample input, only $1$ case is given.

For example, the game proceeds as follows.

  • Initially, $(A_1,A_2,A_3)=(-1,-1,-1)$.
  • Alice chooses $x=2,i=2$ and performs her steps. Now $(A_1,A_2,A_3)=(-1,2,-1)$.
  • Bob chooses $x=1,i=3$ and performs his steps. Now $(A_1,A_2,A_3)=(-1,2,1)$.
  • Alice chooses $x=3,i=1$ and performs her steps. Now $(A_1,A_2,A_3)=(3,2,1)$.
  • There is no $i$ that Bob can declare, so the game ends.
  • The operations are performed on $A$. The $1$st operation makes $A=(A_1+A_2,A_2+A_3)=(5,3)$, and the $2$nd operation makes $A=(A_1+A_2)=(8)$. Therefore, $X=8$.
  • Since $S$ is Even and $X$ is even, Alice wins.

The players are not necessarily acting optimally here, but it can be shown that the winner is Alice even when both act optimally.

In this play, for example, it would be illegal for Alice to choose $x=1$ in her $2$nd turn, because $A_3=1$, so $1$ is already contained.

It would also be illegal for Bob to choose $i=2$ in his $1$st turn, because $A_2=2$, which is not $-1$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。