AB 对 BAAI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given a string $S$ of length $N$ consisting of A and B. Abel and Bart play a game using $S$. Starting with Abel, they take turns performing the following operation.
给定一个长度为 $N$、由 A 和 B 组成的字符串 $S$。Abel 和 Bart 使用 $S$ 进行游戏。Abel 先手,双方轮流进行以下操作。AI (CI翻译)
- Abel chooses one substring
ABof$S$and deletes it. - Bart chooses one substring
BAof$S$and deletes it.
- Abel 选择
$S$中的一个子串AB并将其删除。 - Bart 选择
$S$中的一个子串BA并将其删除。
The person who cannot perform the operation on their turn loses, and the other person wins. Find the winner when both players act optimally.
轮到某位玩家时,如果无法进行操作,则该玩家输,另一位玩家获胜。假设双方都采取最优策略,求最终的获胜者。AI (CI翻译)
Solve $T$ test cases for each input.
对于每组输入,求解 $T$ 个测试用例。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1 \le T \le 2 \times 10^5$$1 \le N \le 2 \times 10^5$$S$is a string of length$N$consisting ofAandB.- The sum of
$N$over the$T$test cases is at most$2 \times 10^5$. - All input values are integers.
$1 \le T \le 2 \times 10^5$$1 \le N \le 2 \times 10^5$$S$是一个长度为$N$、由A和B组成的字符串。- 所有测试用例的
$N$之和不超过$2 \times 10^5$。 - 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_TAI (CI翻译)
Each test case is given in the following format:
每个测试用例按以下格式给出:AI (CI翻译)
N
S
N
SAI (CI翻译)
Output
输出格式
AI (CI翻译)Output $T$ lines. The $i$-th line should contain Abel if Abel wins the $i$-th test case, and Bart otherwise.
输出 $T$ 行。第 $i$ 行如果第 $i$ 个测试用例由 Abel 获胜,则输出 Abel;否则输出 Bart。AI (CI翻译)
样例
2
5
ABAAB
5
AABBA
Abel
Bart
3
7
BAABAAA
13
AABBAAAABABBA
20
ABAABABABBAAABBABABA
Bart
Abel
Abel
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。