QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 10

#6028. 纸牌游戏 [A]

Statistics

Bajtek 和 Bitek 是世界级的《魔法生物》卡牌游戏大师。今晚将举行一场史诗般的对决,决定谁将获得终身“大宗师”称号。

《魔法生物》的游戏规则相当独特。每位玩家拥有 $n$ 副不同的卡组。正式比赛前有一个卡组选择阶段。从 Bajtek 开始,玩家轮流弃掉对方的一副卡组。当每位玩家只剩下一副卡组时,游戏将进入更加激动人心的第二阶段,这也是游戏的最后阶段。有趣的是,第二阶段的进程既不依赖于玩家的策略,也不依赖于运气——对于每一对可能进入最终对决的卡组组合,其结果是预先确定的——要么是 Bajtek 获胜,要么是 Bitek 获胜,要么是平局。

你的任务是判断 Bajtek 是否拥有必胜策略。如果 Bajtek 在双方都采取最优策略弃牌的情况下,能在最终对决中获胜,则称 Bajtek 拥有必胜策略。如果 Bajtek 没有必胜策略,则需要判断他是否至少拥有平局策略,即在双方都采取最优策略的情况下,他能否确保对手无法获得“大宗师”称号。

输入格式

输入的第一行包含一个整数 $t$ ($1 \le t \le 20$),表示测试用例的数量。

每个测试用例的第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 100\,000, 0 \le m \le 200\,000$),分别表示每位玩家拥有的卡组数量以及在第二阶段中不会导致平局的卡组对数。每位玩家的卡组编号从 $1$ 到 $n$。接下来有 $m$ 行,每行格式为 $a\ w\ b$ ($1 \le a, b \le n, w \in \{<, >\}$)。如果 $w = <$,则表示 Bajtek 的 $a$ 号卡组输给 Bitek 的 $b$ 号卡组。如果 $w = >$,则表示 Bajtek 的 $a$ 号卡组赢过 Bitek 的 $b$ 号卡组。对于给定的有序卡组编号对 $(a, b)$(分别对应 Bajtek 和 Bitek),每种关系在测试用例描述中最多出现一次;如果某对 $(a, b)$ 没有出现,则意味着 Bajtek 的 $a$ 号卡组与 Bitek 的 $b$ 号卡组对决的结果为平局。

输出格式

输出 $t$ 行,每行对应一个测试用例的结果,顺序与输入中的顺序一致。

如果 Bajtek 拥有必胜策略,输出 WYGRANA;如果他没有必胜策略但拥有平局策略,输出 REMIS;否则输出 PRZEGRANA

样例

输入 1

3
5 5
5 > 5
1 > 5
3 > 5
4 > 5
2 > 5
2 2
1 > 1
1 > 2
1 1
1 < 1

输出 1

WYGRANA
REMIS
PRZEGRANA

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.