CF2263A.Min Max Game

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Bessie and Elsie are playing a game on a binary array aa of length nn.

The players alternate turns, with Bessie moving first. On Bessie's turn, she chooses two adjacent elements xx and yy and replaces them with the single value max⁡(x,y)\max(x,y).

On Elsie's turn, she chooses two adjacent elements xx and yy and replaces them with the single value min⁡(x,y)\min(x,y).

After each move, the length of the array decreases by 11. The game ends when only one element remains. Bessie wins if the final element is 11, and Elsie wins if the final element is 00.

Assuming both players play optimally, determine who wins.

贝茜和埃尔西正在一个长度为 nn 的二进制数组 aa 上进行一场游戏。

两名玩家轮流行动,贝茜先手。在贝茜的回合中,她选择两个相邻元素 xx 和 yy,并将它们替换为单个值 max⁡(x,y)\max(x,y)。

在埃尔西的回合中,她选择两个相邻元素 xx 和 yy,并将它们替换为单个值 min⁡(x,y)\min(x,y)。

每次操作后,数组长度减少 11。当数组中仅剩一个元素时,游戏结束。若最终元素为 11,则贝茜获胜;若最终元素为 00,则埃尔西获胜。

假设双方均以最优策略进行游戏,请判断谁将获胜。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains a single integer nn (2≤n≤1002 \leq n \leq 100).

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤10 \leq a_i \leq 1).

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤5001 \le t \le 500)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(2≤n≤1002 \leq n \leq 100)。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai≤10 \leq a_i \leq 1)。

输出格式

For each test case, you should output the name of who wins on a new line.

对于每个测试用例,您应在新的一行输出获胜者的名字。

输入输出样例

  • 输入#1

    3
    5
    1 0 1 0 1
    3
    0 0 1
    4
    1 1 0 0

    输出#1

    Bessie
    Elsie
    Bessie

说明/提示

For the first test case, Bessie can guarantee a win. One possible game is as follows: $$ [\color{red}{1},\color{red}{0},1,0,1] \to [1,\color{red}{1},\color{red}{0},1] \to [\color{red}{1},\color{red}{0},1] \to [\color{red}{1},\color{red}{1}] \to [1]. $$ The final value is 11, so Bessie wins (the red highlight denotes the two adjacent elements picked on that turn).

For the second test case, no matter which move Bessie makes, Elsie can make the final value 00. Therefore, Elsie wins.

For the third test case, one possible winning game for Bessie is: $$ [1,\color{red}{1},\color{red}{0},0] \to [1,\color{red}{1},\color{red}{0}] \to [\color{red}{1},\color{red}{0}] \to [1]. $$ The final value is 11, so Bessie wins.

对于第一个测试用例,贝西可以确保获胜。一种可能的游戏过程如下:

\[\color{red}{1},\color{red}{0},1,0,1\] \to \[1,\color{red}{1},\color{red}{0},1\] \to \[\color{red}{1},\color{red}{0},1\] \to \[\color{red}{1},\color{red}{1}\] \to \[1\].

最终值为 11,因此贝西获胜(红色高亮表示该回合所选的两个相邻元素)。

对于第二个测试用例,无论贝西如何操作,埃尔西都能使最终值为 00。因此,埃尔西获胜。

对于第三个测试用例,贝西的一种获胜策略如下:

\[1,\color{red}{1},\color{red}{0},0\] \to \[1,\color{red}{1},\color{red}{0}\] \to \[\color{red}{1},\color{red}{0}\] \to \[1\].

最终值为 11,因此贝西获胜。

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

首页