AtCoder Regular Contest-- 219
D
网格游戏
Grid Game
AtCoder
⌀ 1716
原题
← CE →

网格游戏AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

There is an $N \times N$ grid. The cell at the $i$-th row from the top and the $j$-th column from the left is denoted as cell $(i,j)$. Cell $(i,j)$ initially contains $A_{i,j}$ stones.

有一个 $N \times N$ 的网格。从上往下数第 $i$ 行、从左往右数第 $j$ 列的单元格记为 $(i,j)$。单元格 $(i,j)$ 中初始有 $A_{i,j}$ 个石子。AI (CI翻译)

Alice and Bob play the following game using this grid.

Alice 和 Bob 使用这个网格进行如下游戏。AI (CI翻译)

  • Starting with Alice, the two players alternate taking turns.
  • On each turn, the player chooses a cell and moves at least $1$ and at most $K$ stones from it together to an adjacent cell above or to the left. Specifically, the following steps are performed in order:
  • Choose a cell $(i,j)$ that contains at least $1$ stone. Cell $(1,1)$ cannot be chosen.
    • Let $c$ be the number of stones in cell $(i,j)$, and choose an integer $x$ satisfying $1 \le x \le \min(c,K)$.
    • Choose as the destination either cell $(i-1,j)$ (if it exists) or cell $(i,j-1)$ (if it exists), then remove $x$ stones from cell $(i,j)$ and move all of them to that cell.
  • 两名玩家从 Alice 开始轮流行动。
  • 每次行动时,玩家选择一个单元格,将其中至少 $1$ 个、至多 $K$ 个石子一起移动到它上方或左方的相邻单元格。具体按以下步骤进行:
  • 选择一个包含至少 $1$ 个石子的单元格 $(i,j)$。不能选择单元格 $(1,1)$。
    • 设单元格 $(i,j)$ 中有 $c$ 个石子,并选择一个满足 $1 \le x \le \min(c,K)$ 的整数 $x$。
    • 将目的地选择为单元格 $(i-1,j)$(如果存在)或单元格 $(i,j-1)$(如果存在),然后从单元格 $(i,j)$ 中移除 $x$ 个石子,并将它们全部移动到该单元格。
AI (CI翻译)

The player who cannot take a turn first loses.

无法行动的玩家输掉游戏。AI (CI翻译)

Determine which player wins when both play optimally.

假设双方都采取最优策略,判断最终哪位玩家获胜。AI (CI翻译)

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

给定 $T$ 组测试数据,请分别求出每组测试数据的答案。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1\le T$
  • $2\le N\le 100$
  • $1\le K\le 10^9$
  • $0\le A_{i,j}\le 10^9$
  • The sum of $N^2$ over all test cases is at most $3\times 10^5$.
  • All input values are integers.
  • $1\le T$
  • $2\le N\le 100$
  • $1\le K\le 10^9$
  • $0\le A_{i,j}\le 10^9$
  • 所有测试数据中 $N^2$ 的总和不超过 $3\times 10^5$。
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
AI (CI翻译)

Each test case is given in the following format:

每组测试数据按以下格式给出:AI (CI翻译)

N K
A_{1,1} A_{1,2} \ldots A_{1,N}
A_{2,1} A_{2,2} \ldots A_{2,N}
\vdots
A_{N,1} A_{N,2} \ldots A_{N,N}

N K
A_{1,1} A_{1,2} \ldots A_{1,N}
A_{2,1} A_{2,2} \ldots A_{2,N}
\vdots
A_{N,1} A_{N,2} \ldots A_{N,N}
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the answers for the test cases in order, separated by newlines.

按顺序输出各组测试数据的答案,每组答案占一行。AI (CI翻译)

For each test case, output Alice if Alice wins when both play optimally, and Bob if Bob wins.

对于每组测试数据,如果双方都采取最优策略时 Alice 获胜,输出 Alice;如果 Bob 获胜,输出 Bob。AI (CI翻译)

样例

Input #1
3
2 2
0 1
3 2
3 1
1 1 1
1 1 1
1 1 1
4 4
3 8 5 3
4 2 0 6
0 9 10 4
1 9 7 10
Output #1
Alice
Bob
Alice
Consider the first test case. For example, the game may proceed as follows (note that the players are not necessarily playing optimally): - Alice's turn: Choose cell $(2,2)$ and remove $2$ stones. Move the removed stones to cell $(1,2)$. - Bob's turn: Choose cell $(1,2)$ and remove $2$ stones. Move the removed stones to cell $(1,1)$. - Alice's turn: Choose cell $(2,1)$ and remove $2$ stones. Move the removed stones to cell $(1,1)$. - Bob's turn: Choose cell $(2,1)$ and remove $1$ stone. Move the removed stone to cell $(1,1)$. - Alice's turn: Choose cell $(1,2)$ and remove $1$ stone. Move the removed stone to cell $(1,1)$. - Bob's turn: Bob cannot take a turn and loses. By playing optimally, Alice can always beat Bob. Thus, output `Alice` on the first line.
题目信息
题号
arc219_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。