QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#17879. 叠叠乐游戏

Statistiques

Yesyes 和 Nono 正在玩叠叠乐(Jenga)游戏。叠叠乐的规则如下:

有一个由 $n$ 层积木组成的塔。每层由三块长条积木组成。同一层内的积木彼此平行。相邻两层的积木互相垂直。在游戏开始时,某些积木可能已经缺失。两名玩家轮流进行操作。在一次操作中,玩家必须选择一块积木并将其从塔中移出,前提是移出后塔仍能保持稳定。如果满足以下所有条件,则称塔是稳定的:

  • 每层至少包含一块积木。
  • 如果某层恰好包含一块积木,则它必须是中间的那块。
  • 最顶层必须包含三块积木。

无法进行任何操作的玩家输掉游戏。给定塔的初始状态,其中可能已经移出了一些积木。保证给定的叠叠乐塔的初始状态是稳定的。

你的任务是确定哪位玩家将获胜。两位玩家在对抗时总是使用最优策略。Yesyes 先手。Yesyes 和 Nono 都是叠叠乐专家,因此他们在移出积木时不会犯任何错误。

请注意,在这个版本的叠叠乐中,玩家不会将移出的积木放回塔顶。

输入格式

第一行输入包含测试用例的数量 $T$。

每个测试用例的第一行包含叠叠乐塔的初始高度 $N$。

接下来的 $N$ 行中,每行包含一个长度为 3 且仅由 01 组成的字符串,表示每层的初始状态,从最顶层开始。0 表示该位置没有积木,1 表示该位置有积木。保证给定的叠叠乐塔的初始状态是稳定的。

输出格式

对于每个测试用例,在一行中输出获胜者。

数据范围

  • $1 \le T \le 1000$
  • $2 \le N \le 400\,000$
  • 所有测试用例的 $N$ 之和不超过 $400\,000$。

样例

输入样例 1

2
6
111
101
010
111
110
111
2
111
101

输出样例 1

Yesyes
Nono

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.