Round Robin

AtCoder
IDabc241_g
Time2000ms
Memory256MB
Difficulty
$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$ [samples]
Samples
Input #1
4 2
2 1
2 3
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.
Input #2
3 3
1 2
2 3
3 1
Output #2
It is possible that no player can become the unique winner.
Input #3
7 9
6 5
1 2
3 4
5 3
6 2
1 5
3 2
6 4
1 4
Output #3
1 3 6 7
API Response (JSON)
{
  "problem": {
    "name": "Round Robin",
    "description": {
      "content": "$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 ot",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc241_g"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "$N$ players numbered $1$ through $N$ will participate in a round-robin tournament.  \nSpecifically, for every pair $(i,j) (1\\leq i \\lt j \\leq N)$, Player $i$ and Player $j$ play a match against each ot...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments