最大值最小值游戏AI (CI翻译)
Bessie and Elsie are playing a game on a binary array $a$ of length $n$.
Bessie 和 Elsie 在一个长度为 $n$ 的二进制数组 $a$ 上进行游戏。AI (CI翻译)
The players alternate turns, with Bessie moving first. On Bessie's turn, she chooses two adjacent elements $x$ and $y$ and replaces them with the single value $\max(x,y)$.
双方轮流行动,由 Bessie 先手。在 Bessie 的回合,她选择两个相邻元素 $x$ 和 $y$,并将它们替换为单个值 $\max(x,y)$。AI (CI翻译)
On Elsie's turn, she chooses two adjacent elements $x$ and $y$ and replaces them with the single value $\min(x,y)$.
在 Elsie 的回合,她选择两个相邻元素 $x$ 和 $y$,并将它们替换为单个值 $\min(x,y)$。AI (CI翻译)
After each move, the length of the array decreases by $1$. The game ends when only one element remains. Bessie wins if the final element is $1$, and Elsie wins if the final element is $0$.
每次操作后,数组长度减少 $1$。当数组中只剩下一个元素时,游戏结束。如果最终元素为 $1$,则 Bessie 获胜;如果最终元素为 $0$,则 Elsie 获胜。AI (CI翻译)
Assuming both players play optimally, determine who wins.
假设双方都采取最优策略,判断谁将获胜。AI (CI翻译)
Input
输入格式
AI (CI翻译)Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.
每个测试包含多个测试用例。第一行包含测试用例数量 $t$($1 \le t \le 500$)。接下来描述各个测试用例。AI (CI翻译)
The first line of each test case contains a single integer $n$ ($2 \leq n \leq 100$).
每个测试用例的第一行包含一个整数 $n$($2 \le n \le 100$)。AI (CI翻译)
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq 1$).
每个测试用例的第二行包含 $n$ 个整数 $a_1, a_2, \ldots, a_n$($0 \le a_i \le 1$)。AI (CI翻译)
Output
输出格式
AI (CI翻译)For each test case, you should output the name of who wins on a new line.
对于每个测试用例,在新的一行输出获胜者的名字。AI (CI翻译)
Note
说明
AI (CI翻译)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 $1$, so Bessie wins (the red highlight denotes the two adjacent elements picked on that turn).
对于第一个测试用例,Bessie 可以保证获胜。一种可能的游戏过程如下:
$$ [\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]. $$
最终值为 $1$,因此 Bessie 获胜(红色标记表示该回合选择的两个相邻元素)。AI (CI翻译)
For the second test case, no matter which move Bessie makes, Elsie can make the final value $0$. Therefore, Elsie wins.
对于第二个测试用例,无论 Bessie 进行哪种操作,Elsie 都可以使最终值为 $0$。因此,Elsie 获胜。AI (CI翻译)
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 $1$, so Bessie wins.
对于第三个测试用例,Bessie 的一种获胜过程如下:
$$ [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]. $$
最终值为 $1$,因此 Bessie 获胜。AI (CI翻译)
样例
3
5
1 0 1 0 1
3
0 0 1
4
1 1 0 0
Bessie
Elsie
Bessie
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。