102416: [AtCoder]ABC241 G - Round Robin

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $600$ points

Problem Statement

$N$ players numbered $1$ through $N$ will participate in a round-robin tournament.
Specifically, for every pair $(i,j) (1\leq i \lt j \leq N)$, Player $i$ and Player $j$ play a match against each other once, for a total of $\frac{N(N-1)}{2}$ matches.
In every match, one of the players will be a winner and the other will be a loser; there is no draw.

$M$ matches have already ended. In the $i$-th match, Player $W_i$ won Player $L_i$.

List all the players who may become the unique winner after the round-robin tournament is completed.
A player is said to be the unique winner if the number of the player's wins is strictly greater than that of any other player.

Constraints

  • $2\leq N \leq 50$
  • $0\leq M \leq \frac{N(N-1)}{2}$
  • $1\leq W_i,L_i\leq N$
  • $W_i \neq L_i$
  • If $i\neq j$, then $(W_i,L_i) \neq (W_j,L_j)$.
  • $(W_i,L_i) \neq (L_j,W_j)$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $M$
$W_1$ $L_1$
$W_2$ $L_2$
$\vdots$
$W_M$ $L_M$

Output

Let $A=(A_1,A_2,\dots,A_K) (A_1\lt A_2 \lt \dots \lt A_K)$ be the set of indices of players that may become the unique winner. Print $A$ in the increasing order, with spaces in between.
In other words, print in the following format.

$A_1$ $A_2$ $\dots$ $A_K$

Sample Input 1

4 2
2 1
2 3

Sample Output 1

2 4

Players $2$ and $4$ may become the unique winner, while Players $1$ and $3$ cannot.
Note that output like 4 2 is considered to be incorrect.


Sample Input 2

3 3
1 2
2 3
3 1

Sample Output 2


It is possible that no player can become the unique winner.


Sample Input 3

7 9
6 5
1 2
3 4
5 3
6 2
1 5
3 2
6 4
1 4

Sample Output 3

1 3 6 7

Input

题意翻译

$ N $ 名玩家进行循环赛。总共进行 $ \frac{N(N-1)}{2} $ 场比赛,比赛必然分出胜负,不存在平局,一场比赛中胜者获得 $ 1 $ 分。 当前进行了 $ M $ 场比赛,其中第 $ i $ 场 $ W_i $ 打败了 $ L_i $。 我们称一个玩家可能获胜当且仅当存在一种比赛结果使得该玩家的得分严格高于其它所有玩家。求哪些玩家可能获胜(**按从小到大输出答案**)。

Output

分数:$600$分

问题描述

编号为$1$到$N$的$N$名选手将参加一个循环赛。

具体来说,对于每一对$(i,j) (1\leq i \lt j \leq N)$,选手$i$和选手$j$将互相比赛一次,总共比赛$\frac{N(N-1)}{2}$场。

每场比赛中,其中一名选手将是胜者,另一名将是负者;没有平局。

已经结束了$M$场比赛。在第$i$场比赛中,选手$W_i$赢了选手$L_i$。

列出所有可能在循环赛结束后成为唯一胜者的选手。

如果一名选手的胜利次数严格多于其他任何选手,那么该选手被认为是唯一胜者。

约束

  • $2\leq N \leq 50$
  • $0\leq M \leq \frac{N(N-1)}{2}$
  • $1\leq W_i,L_i\leq N$
  • $W_i \neq L_i$
  • 如果$i\neq j$,则$(W_i,L_i) \neq (W_j,L_j)$。
  • $(W_i,L_i) \neq (L_j,W_j)$
  • 输入中的所有值都是整数。

输入

从标准输入给出以下格式的输入:

$N$ $M$
$W_1$ $L_1$
$W_2$ $L_2$
$\vdots$
$W_M$ $L_M$

输出

令$A=(A_1,A_2,\dots,A_K) (A_1\lt A_2 \lt \dots \lt A_K)$表示可能成为唯一胜者的选手的索引集合。按照递增顺序打印$A$,并在其中间用空格分隔。

换句话说,按照以下格式打印:

$A_1$ $A_2$ $\dots$ $A_K$

样例输入 1

4 2
2 1
2 3

样例输出 1

2 4

选手$2$和$4$可能成为唯一胜者,而选手$1$和$3$不可能成为唯一胜者。

请注意,像4 2这样的输出被认为是错误的。


样例输入 2

3 3
1 2
2 3
3 1

样例输出 2


有可能没有选手可以成为唯一胜者。


样例输入 3

7 9
6 5
1 2
3 4
5 3
6 2
1 5
3 2
6 4
1 4

样例输出 3

1 3 6 7

加入题单

上一题 下一题 算法标签: