atcoder#ABC241G. [ABC241G] Round Robin
[ABC241G] Round Robin
Score : points
Problem Statement
players numbered through will participate in a round-robin tournament. Specifically, for every pair , Player and Player play a match against each other once, for a total of matches. In every match, one of the players will be a winner and the other will be a loser; there is no draw.
matches have already ended. In the -th match, Player won Player .
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
- If , then .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
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 in the increasing order, with spaces in between. In other words, print in the following format.
4 2
2 1
2 3
2 4
Players and may become the unique winner, while Players and cannot.
Note that output like 4 2
is considered to be incorrect.
3 3
1 2
2 3
3 1
It is possible that no player can become the unique winner.
7 9
6 5
1 2
3 4
5 3
6 2
1 5
3 2
6 4
1 4
1 3 6 7