問題一覧 > 通常問題

No.1716 Bonus Nim

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 78
作問者 : nok0 / テスター : zkou Kite_kuma ygussany
お気に入りにしたユーザー ProblemId : 6579 / 自分の提出
問題文最終更新日: 2021-10-16 18:47:00
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 319 (順位表) の他の問題:

Problem Statement

Alice and Bob play a game.

Initially there are $N$ piles, and the $i$-th pile has $A_i$ stones on it.

Starting with Alice, the $2$ players alternately and repeatedly choose one of the following operations.

  1. Choose $1$ pile that has $1$ or more stones remaining. If the chosen pile has $X$ stones, remove any number of stones between $1$ and $X$, inclusive, from that pile. If all the stones are removed, that is, if $X$ stones are removed, the player gets $1$ coin as a bonus.
  2. Discard $1$ coin that the player has.

The player who first becomes unable to perform an operation loses.

Initially, neither Alice nor Bob has any coins. Determine who wins when both Alice and Bob act optimally in order to win.

For each input file, answer $T$ test cases.

Constraints

  • All input values are integers.
  • $1 \le T\le 2 \times 10^5$
  • $1 \le N \le 2 \times 10^5 $
  • $1 \le A_i\le 10^9 $
  • In $1$ input file, the sum of $N$ is at most $5\times 10^5$.

Input

The input is given from standard input in the following format.

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

Each test case is given in the following format.

$N$
$A_1$ $A_2$ $\dots$ $A_N$

Output

Output $T$ lines. On the $i\ (1\le i \le T)$-th line, output Alice if the winner of the $i$-th test case is Alice, and Bob if it is Bob.

Sample

Sample 1
Input
2
1
3
2
1 1
Output
Alice
Bob

For example, the following scenario is possible in the $2$-nd game.

  • Alice performs operation $1$, choosing the $1$-st pile and removing $1$ stone. Since the $1$-st pile has no stones left, she gets $1$ coin.
  • Bob performs operation $1$, choosing the $2$-nd pile and removing $1$ stone. Since the $2$-nd pile has no stones left, he gets $1$ coin.
  • Alice performs operation $2$, discarding $1$ coin.
  • Bob performs operation $2$, discarding $1$ coin.
  • Alice cannot perform any more operations, so she loses. Bob wins.

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