CF1747C.Swap Game

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice and Bob are playing a game on an array aa of nn positive integers. Alice and Bob make alternating moves with Alice going first.

In his/her turn, the player makes the following move:

  • If a1=0a_1 = 0, the player loses the game, otherwise:
  • Player chooses some ii with 2≤i≤n2\le i \le n. Then player decreases the value of a1a_1 by 11 and swaps a1a_1 with aia_i.

Determine the winner of the game if both players play optimally.

爱丽丝和鲍勃正在一个包含 nn 个正整数的数组 aa 上进行一场游戏。爱丽丝和鲍勃轮流行动,爱丽丝先手。

在自己的回合中,玩家执行如下操作:

  • 若 a1=0a_1 = 0,则该玩家输掉游戏;否则:
  • 玩家选择某个下标 ii(满足 2≤i≤n2 \le i \le n),将 a1a_1 的值减 11,然后交换 a1a_1 与 aia_i。

若双方均采取最优策略,请判断游戏的获胜者。

输入格式

The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤2⋅104)(1 \leq t \leq 2 \cdot 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (2≤n≤105)(2 \leq n \leq 10^5) — the length of the array aa.

The second line of each test case contains nn integers a1,a2…ana_1,a_2 \ldots a_n (1≤ai≤109)(1 \leq a_i \leq 10^9) — the elements of the array aa.

It is guaranteed that sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

输入包含多个测试用例。第一行包含一个整数 tt (1≤t≤2⋅104)(1 \leq t \leq 2 \cdot 10^4),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn (2≤n≤105)(2 \leq n \leq 10^5),表示数组 aa 的长度。

每个测试用例的第二行包含 nn 个整数 a1,a2…ana_1,a_2 \ldots a_n (1≤ai≤109)(1 \leq a_i \leq 10^9),表示数组 aa 的元素。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, if Alice will win the game, output "Alice". Otherwise, output "Bob".

You can output each letter in any case. For example, "alIcE", "Alice", "alice" will all be considered identical.

对于每个测试用例,如果 Alice 将赢得游戏,则输出 “Alice”;否则输出 “Bob”。

你可以以任意大小写形式输出每个字母。例如,“alIcE”、“Alice”、“alice” 均被视为相同。

输入输出样例

  • 输入#1

    3
    2
    1 1
    2
    2 1
    3
    5 4 4

    输出#1

    Bob
    Alice
    Alice

说明/提示

In the first testcase, in her turn, Alice can only choose i=2i = 2, making the array equal [1,0][1, 0]. Then Bob, in his turn, will also choose i=2i = 2 and make the array equal [0,0][0, 0]. As a1=0a_1 = 0, Alice loses.

In the second testcase, once again, players can only choose i=2i = 2. Then the array will change as follows: [2,1]→[1,1]→[1,0]→[0,0][2, 1] \to [1, 1] \to [1, 0] \to [0, 0], and Bob loses.

In the third testcase, we can show that Alice has a winning strategy.

在第一个测试用例中,轮到 Alice 时,她只能选择 i=2i = 2,使数组变为 [1,0][1, 0]。随后轮到 Bob,他同样选择 i=2i = 2,使数组变为 [0,0][0, 0]。由于此时 a1=0a_1 = 0,Alice 失败。

在第二个测试用例中,双方玩家依然只能选择 i=2i = 2。数组的变化过程如下:[2,1]→[1,1]→[1,0]→[0,0][2, 1] \to [1, 1] \to [1, 0] \to [0, 0],最终 Bob 失败。

在第三个测试用例中,可以证明 Alice 存在必胜策略。

输入解题思路,AI测评打分。不知道怎么写?

首页