QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 100

#4486. 吹牛骰子

统计

在神秘的东方,有一种古老的骰子游戏——“吹牛”。现在 YahAHa 和 Peanut 正在玩这个游戏。

游戏规则如下:

游戏中共有 2 名玩家。每名玩家的杯中有 $n$ 个骰子。双方各掷一次骰子。

玩家轮流进行。YahAHa 先手。在第一回合,YahAHa 可以声称:“2 个杯子中共有 $x$ ($x \ge 1$) 个点数为 $y$ ($1 \le y \le 6$) 的骰子”。

随后 Peanut 有 2 种选择:

  1. 挑战 YahAHa。如果有人发起挑战,游戏结束。双方打开各自的杯子。如果杯中确实有 $x$ 个点数为 $y$ 的骰子,则 YahAHa 获胜,否则 Peanut 获胜。
  2. 继续声称,但只能声称:“2 个杯子中共有 $x_1$ ($x_1 > x$) 个点数为 $y_1$ ($1 \le y_1 \le 6$) 的骰子”或者“2 个杯子中共有 $x_2$ ($x_2 = x$) 个点数为 $y_2$ ($y_2 > y$) 的骰子”。

在 Peanut 声称之后,YahAHa 继续选择挑战或声称。双方轮流进行,直到有人发起挑战,游戏结束。

为了增加游戏的趣味性,这里有一些特殊规则:

  1. 如果没有人声称过“2 个杯子中有 $x$ 个点数为 1 的骰子”,那么点数为 1 的骰子可以被视为任意点数。
  2. 如果所有骰子的点数相同,则视为额外多出一个相同点数的骰子。例如,如果有 5 个骰子,且所有骰子点数均为 6,则视为有 6 个点数为 6 的骰子。
  3. 如果每个骰子的点数都不同,则视为“2 个杯子中有 1 个点数为任意点数的骰子”。例如,如果有 5 个骰子,点数分别为 1, 2, 3, 4, 5。则视为“2 个杯子中有 1 个点数为 1 的骰子”、“2 个杯子中有 1 个点数为 2 的骰子”,以此类推,直到“2 个杯子中有 1 个点数为 5 的骰子”。

YahAHa 和 Peanut 不喜欢纯粹的运气游戏,所以他们想在已知 2 个杯子中所有骰子点数的情况下进行游戏。

给定他们掷出的所有骰子点数。如果双方都采取最优策略,请找出谁会赢得游戏。

输入格式

每个测试包含多个测试用例。第一行包含测试用例数量 $T$ ($1 \le T \le 30$)。

每个测试用例的描述如下:

第一行包含一个整数 $n$ ($2 \le n \le 2 \times 10^5$),表示骰子的数量。

下一行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$。第 $i$ 个整数 $a_i$ 表示 YahAHa 的第 $i$ 个骰子的点数。

下一行包含 $n$ 个整数 $b_1, b_2, \dots, b_n$。第 $i$ 个整数 $b_i$ 表示 Peanut 的第 $i$ 个骰子的点数。

输出格式

对于每个测试用例:

如果 YahAHa 获胜,输出 "Win!";如果 Peanut 获胜,输出 "Just a game of chance."。

样例

样例输入 1

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

样例输出 1

Win!

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.