AT_arc225_b.Independent Nim

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

There is an integer sequence AA of length NN. Each element of AA is 00 or 11.

Alice and Bob play a game. Starting with Alice, they alternately perform the following operation.

  • Choose one or more elements of AA that are 11, and set them to 00. Here, it is forbidden to choose adjacent elements simultaneously.

The player who is first unable to perform the operation loses.

Determine which player wins when both players play optimally.

You are given TT test cases; solve each of them.

有一个长度为 NN 的整数序列 AA,其中每个元素均为 00 或 11。

Alice 和 Bob 进行一场游戏。游戏由 Alice 先手,双方轮流执行以下操作:

  • 选择 AA 中一个或多个值为 11 的元素,并将它们全部置为 00。注意:禁止同时选择相邻的元素。

无法执行操作的玩家判负。

当双方均采取最优策略时,请判断哪位玩家获胜。

你将得到 TT 组测试数据,请对每组数据求解。

输入格式

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

TT
case1\text{case}_1
case2\text{case}_2
⋮\vdots
caseT\text{case}_T

Each case is given in the following format:

NN
A1A_1 A2A_2 ⋯\cdots ANA_N

输入从标准输入给出,格式如下:

TT
case1\text{case}_1
case2\text{case}_2
⋮\vdots
caseT\text{case}_T

每个测试用例的格式如下:

NN
A1A_1 A2A_2 ⋯\cdots ANA_N

输出格式

Output TT lines. The ii-th line should contain Alice if Alice wins for casei\text{case}_i, and Bob if Bob wins.

输出 TT 行。第 ii 行应包含 Alice(若 Alice 在第 ii 个测试用例中获胜),或 Bob(若 Bob 在第 ii 个测试用例中获胜)。

输入输出样例

  • 输入#1

    3
    5
    1 0 1 0 1
    2
    1 1
    14
    1 1 1 0 1 1 1 1 0 1 1 1 1 1

    输出#1

    Alice
    Bob
    Alice

说明/提示

Sample 1 Explanation:
For the first test case, Alice can set all elements to 00 by choosing the first, third, and fifth elements and setting them to 00 in her first operation.

Then, Bob cannot perform an operation, so Alice wins when both players play optimally.

For the second test case, Alice can only choose one of the two elements in her first operation.

Constraints

  • 1≤T≤1051 \le T \le 10^5
  • 1≤N≤2×1051 \le N \le 2\times 10^5
  • Ai=0A_i = 0 or Ai=1A_i = 1.
  • The sum of NN over all test cases is at most 2×1052\times 10^5.
  • All input values are integers.

样例 1 解释:
对于第一个测试用例,Alice 可以在她的第一次操作中选择第 1、第 3 和第 5 个元素,并将它们全部设为 00,从而使整个数组的所有元素都变为 00。

随后 Bob 无法执行任何操作,因此在双方均采取最优策略的情况下,Alice 获胜。

对于第二个测试用例,Alice 在她的第一次操作中只能选择两个元素中的一个。

约束条件

  • 1≤T≤1051 \le T \le 10^5
  • 1≤N≤2×1051 \le N \le 2\times 10^5
  • Ai=0A_i = 0 或 Ai=1A_i = 1。
  • 所有测试用例的 NN 之和不超过 2×1052\times 10^5。
  • 所有输入值均为整数。

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

首页