QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100

#3811. 纸牌游戏

Statistiques

Alice 和 Bob 在今年夏天海边度假时发明了一个新游戏。他们只需要一副标有数字的扑克牌。游戏开始时,他们摆出 $P$ 堆牌,所有牌正面朝上,并选择一个非负整数 $K$。之后,他们轮流进行以下操作:

  1. 玩家首先选择其中一堆牌。
  2. 然后,他从该堆牌的顶部移除 $0$ 到 $K$ 张牌,但必须保证移除后该堆牌中至少还剩下一张牌。
  3. 接下来,他查看此时位于该堆牌顶部的牌,并必须移除与该牌面值数量相等的牌(从同一堆牌的顶部移除)。

无法继续移除牌的玩家,或者被迫移除超过该堆牌剩余数量的玩家,即输掉游戏。

在图中,你可以看到一个包含两堆牌且 $K = 1$ 的例子。当前玩家可以:

a) 选择第一堆牌并移除 $0$ 张牌,随后被迫从顶部移除 $1$ 张牌。 b) 选择第二堆牌并移除 $0$ 张牌,随后被迫从顶部移除 $1$ 张牌。 c) 选择第二堆牌并移除 $1$ 张牌,随后被迫从顶部移除 $2$ 张牌。

Alice 意识到 Bob 非常擅长这个游戏,如果给他机会,他总是会赢。幸运的是,这次由 Alice 先手。Alice 能赢得这场游戏吗?

任务

给定牌堆的描述以及玩家开始时最多可以移除的牌数,你的目标是判断 Alice 先手是否能赢得游戏。

输入格式

第一行包含两个空格分隔的整数 $P$(牌堆数量)和 $K$(玩家每回合开始时最多可以移除的牌数)。接下来的 $P$ 行,每行以一个整数 $N$ 开头,表示该堆牌的数量。随后是 $N$ 个空格分隔的整数,表示从底部到顶部该堆牌上的数字。

数据范围

$1 \le P \le 100$:牌堆数量。 $1 \le K \le 10$:玩家开始时最多可以移除的牌数。 $1 \le c \le 10$:每张牌上的数字。 $1 \le N \le 1000$:每堆牌的大小。

输出格式

输出一个字符串,即 "Alice can win." 或 "Bob will win."。

样例

输入 1

4 1
4 1 1 1 1
6 2 1 2 1 2 1
4 1 1 1 1
6 2 1 2 1 2 1

输出 1

Bob will win.

说明 1

这些牌堆是相同的,因此 Bob 总是能够模仿 Alice 的任何移动。

输入 2

2 1
1 1
3 1 2 1

输出 2

Alice can win.

说明 2

Alice 可以先从第二堆牌中移除 $0$ 张牌,然后从顶部移除 $1$ 张牌。接下来会有两种合法的移动,Bob 将进行其中一种,而 Alice 进行另一种。

输入 3

2 2
5 3 2 1 2 1
5 5 4 3 2 1

输出 3

Alice can win.

Figure 1. 一个包含两堆牌且 K = 1 的游戏例子。

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.