QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 1024 MB Total points: 100 Difficulty: [show] Hackable ✓

#10088. 玻璃踏脚石

Statistics

Alice 和 Bob 正在玩一个由字母 “L” 和 “R”(ASCII 码分别为 76 和 82)组成的字符串游戏。他们轮流进行操作,Alice 先手。在每一轮中,玩家从字符串中移除一个字符。

如果结果字符串中不包含子串 “LR”,则 Alice 获胜;如果结果字符串中不包含子串 “RL”,则 Bob 获胜。然而,如果两个事件同时发生,则游戏判定为平局。

上述规则同样适用于初始字符串:例如,如果初始字符串包含子串 “RL” 但不包含子串 “LR”,则没有人会进行任何操作,因为 Alice 直接获胜。

如果双方都采取最优策略,游戏的结果会是什么?Alice 应该如何操作以达到这一结果?

输入格式

第一行包含一个整数 $T$,表示测试用例的数量 ($1 \le T \le 10^6$)。接下来的 $T$ 行描述了各个测试用例。

每个测试用例由一个仅包含字母 “L” 和 “R” 的字符串 $s$ 表示 ($1 \le |s| \le 10^6$)。

所有测试用例中字符串 $s$ 的长度之和不超过 $10^6$。

输出格式

对于每个测试用例,输出 “Alice”、“Bob” 或 “Draw”(不区分大小写),表示游戏的获胜者或平局。在同一行中,输出一个整数 $a$,描述 Alice 的任意一种最优走法。$a$ 是 Alice 在第一轮中移除的字符在字符串 $s$ 中的位置 ($1 \le a \le |s|$)。如果该走法在双方后续均采取最优策略的情况下,不会改变游戏最终结果,则该走法即为最优走法。如果游戏在第一步之前就已经结束,则输出 $a = 0$。

样例

样例输入 1

16
LRRRRLRRLRRRLLLRRL
L
R
RRRRRRRRR
LLLLLLLLLLLLLLL
LRLL
RLRR
RLRL
LLLLRRR
RL
LR
LRLR
LRLLR
LRLRL
LLLLLLLLLLRRRRRRRRLLLLLLRRRR
LLLLLLLLLLRRRRRRRRLLLLLLLLLLLRRRR

样例输出 1

Draw 10
Draw 0
Draw 0
Draw 0
Draw 0
Alice 1
Draw 2
Alice 2
Bob 0
Alice 0
Bob 0
Bob 2
Draw 5
Alice 1
Bob 2
Draw 30

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.