QOJ.ac

QOJ

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

#10505. 锦标赛

统计

在 Bajtocja 举办了电脑游戏《Epiccy Wojownicy》的决赛。共有 $n$ 名通过远程预选赛选出的顶尖选手参加。比赛流程如下:只要场上至少还有两名选手,就会从尚未被淘汰的选手中随机抽取两人进行对决,负者将被淘汰。在《Epiccy Wojownicy》中没有平局,因此在 $n-1$ 场对决后,比赛的获胜者将会产生。

对于某些选手对 $(a, b)$,他们之间直接对决的结果是明确的。那么,哪些选手有机会赢得比赛呢?换句话说,对于哪些选手 $x$,存在一种抽签和对决的顺序,使得 $x$ 最终赢得比赛?

输入格式

输入的第一行包含一个整数 $n$ ($2 \le n \le 500$),表示比赛的初始选手人数。选手编号为 $1$ 到 $n$。

接下来的 $n$ 行中,第 $i$ 行包含一个长度为 $n$ 的字符串 $c_{i,1}c_{i,2} \dots c_{i,n}$。对于每个 $i$,满足 $c_{i,i} = \text{X}$。此外,对于 $i \neq j$,有 $c_{i,j} \in \{\text{W}, \text{P}, ?\}$。$c_{i,j} = \text{W}$ 表示选手 $i$ 在与选手 $j$ 的直接对决中获胜;$c_{i,j} = \text{P}$ 表示选手 $i$ 在与选手 $j$ 的对决中失败;$c_{i,j} = ?$ 表示选手 $i$ 和 $j$ 之间的对决可能以 $i$ 获胜或 $j$ 获胜告终。已知 $c_{i,j} = \text{W}$ 当且仅当 $c_{j,i} = \text{P}$,且 $c_{i,j} = ?$ 当且仅当 $c_{j,i} = ?$。

输出格式

输出所有有机会赢得比赛的选手的编号。编号应按升序排列,每行输出一个编号。

样例

输入 1

4
XPPP
WX?W
W?XW
WPPX

输出 1

2
3

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.