AT_arc218_b.All Minus
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are N non-negative integers A1,A2,…,AN written on a blackboard.
Alice and Bob play a game. Starting with Alice, they alternately perform the following operation, and the player who reduces the number of integers written on the blackboard to 0 wins.
- Let m be the minimum non-negative integer currently written on the blackboard.
- If m>0, choose a positive integer x between 1 and m, inclusive. Replace every integer written on the blackboard with its current value minus x.
- If m=0, erase one or more of the 0s written on the blackboard.
Determine who wins when both players play optimally to win.
T test cases are given; solve each of them.
黑板上写着 N 个非负整数 A1,A2,…,AN。
爱丽丝(Alice)和鲍勃(Bob)进行一场游戏。游戏由爱丽丝先手,双方轮流执行以下操作;将黑板上的数字个数减至 0 的玩家获胜。
- 设 m 为当前黑板上所有数字中最小的非负整数。
- 若 m>0,则选择一个介于 1 到 m(含端点)之间的正整数 x,并将黑板上每个数字均替换为它当前值减去 x;
- 若 m=0,则擦除黑板上一个或多个 0。
当双方均以最优策略进行游戏时,判断谁将获胜。
共给出 T 组测试用例,请对每组用例求解。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N
A1 A2 … AN
输入从标准输入给出,格式如下:
T
case1
case2
⋮
caseT
每个测试用例的格式如下:
N
A1 A2 … AN
输出格式
Output T lines. The i-th line should contain Alice if Alice wins in casei, or Bob if Bob wins.
输出 T 行。第 i 行应包含 Alice(若 Alice 在 casei 中获胜)或 Bob(若 Bob 在 casei 中获胜)。
输入输出样例
输入#1
5 1 2 3 1 1 1 4 1 2 3 4 7 3 1 4 1 5 9 2 3 218 503 2026
输出#1
Alice Bob Bob Bob Alice
说明/提示
Sample 1 Explanation:
For the first test case, one possible game progression is as follows:
- Initially, 2 is written on the blackboard.
- Alice chooses x=1. Now 1 is written on the blackboard.
- Bob chooses x=1. Now 0 is written on the blackboard.
- Alice chooses and erases one 0. Now nothing is written on the blackboard.
When both players play optimally to win, Alice wins.
For the second test case, one possible game progression is as follows:
- Initially, 1,1,1 are written on the blackboard.
- Alice chooses x=1. Now 0,0,0 are written on the blackboard.
- Bob chooses and erases one 0. Now 0,0 are written on the blackboard.
- Alice chooses and erases one 0. Now 0 is written on the blackboard.
- Bob chooses and erases one 0. Now nothing is written on the blackboard.
When both players play optimally to win, Bob wins.
Constraints
- 1≤T≤2×105
- 1≤N≤2×105
- 0≤Ai≤109
- The sum of N over all test cases is at most 2×105.
- All input values are integers.
样例 1 解释:
对于第一个测试用例,一种可能的游戏过程如下:
- 初始时,黑板上写着数字 2。
- 爱丽丝选择 x=1,此时黑板上变为 1。
- 鲍勃选择 x=1,此时黑板上变为 0。
- 爱丽丝选择并擦除一个 0,此时黑板上为空。
当双方均以最优策略进行游戏以争取获胜时,爱丽丝获胜。
对于第二个测试用例,一种可能的游戏过程如下:
- 初始时,黑板上写着 1,1,1。
- 爱丽丝选择 x=1,此时黑板上变为 0,0,0。
- 鲍勃选择并擦除一个 0,此时黑板上变为 0,0。
- 爱丽丝选择并擦除一个 0,此时黑板上变为 0。
- 鲍勃选择并擦除一个 0,此时黑板上为空。
当双方均以最优策略进行游戏以争取获胜时,鲍勃获胜。
约束条件
- 1≤T≤2×105
- 1≤N≤2×105
- 0≤Ai≤109
- 所有测试用例的 N 之和不超过 2×105。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?