QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#5250. 组合锁

الإحصائيات

Alice 和 Bob 正在玩组合锁游戏。他们每个人都有一个由 $N$ 个旋转盘组成的组合锁,每个盘上刻有 $0$ 到 $9$ 的数字。他们的朋友 Charlie 没有锁,但他设计了一个游戏来让他们消磨时间。Charlie 会记录他们锁上对应的数字是否匹配,并用一个差异模式字符串 $S$ 来描述当前的情况。$S$ 的第 $j$ 个字符为 '=' 或 '.',分别表示 Alice 和 Bob 锁上的第 $j$ 位数字是否相同。

Charlie 将担任游戏裁判,Alice 和 Bob 轮流进行操作,Alice 先手。在每一轮中,玩家必须改变自己组合锁上的一个数字。由于 Charlie 只记录差异模式,因此为了使操作有效,该模式必须发生改变。此外,Charlie 比较迷信,他列出了一份在游戏过程中不得出现的模式列表 $P_i$。Charlie 的主要任务是执行以下规则:在游戏过程中,任何差异模式不得重复出现。无法进行有效操作的玩家输掉游戏。

编写一个程序,在双方均采取最优策略的情况下,确定游戏的获胜者。

输入格式

第一行包含测试用例的数量 $T$。每个测试用例的第一行包含两个空格分隔的整数 $N$ 和 $C$。接下来两行描述了 Alice 和 Bob 组合锁的初始配置。锁的配置是一个长度为 $N$ 的数字字符串。接下来的 $C$ 行描述了 Charlie 的迷信模式 $P_i$。

迷信列表中不包含重复项,且保证初始锁配置的差异模式不在迷信列表中。

数据范围

  • $1 \le T \le 20$
  • $1 \le N \le 10$
  • $0 \le C \le 1000$

输出格式

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

样例

输入 1

3
2 2
12
89
=.
==
3 1
204
101
.==
3 2
000
000
...
==.

输出 1

Alice
Bob
Bob

说明

在第一个样例中,Alice 唯一合法的操作是将第二个数字从 $2$ 改为 $9$。任何其他操作要么因为没有改变差异模式而无效,要么因为会导致出现迷信模式而无效。Bob 没有合法的操作,因此 Alice 获胜。

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.