Problem H
Schedule the football tournament
V-League 2017 consists of 2$N$ football teams (indexed from 1 to 2$N$), the league is conducted in the form of a round-robin tournament. The tournament consists of 2$N$-1 rounds, each round consists of $N$ matches. Each round, a team participates in a match. After 2$N$-1 rounds, each team competes all other 2$N$-1 teams in turn, each team exactly once. To increase the tension, the organizer of league expects the final round to include as many derby matches as possible. In fact, there are $K$ derby matches: Team $u_ i$ competes Team $v_ i$, $i=1,\ldots ,K$.
It is a challenge to schedule the tournament satisfying the organizer’s expectation. Your task is to help the organizer to schedule the tournament.
Input
-
The first line contains two integers $N$ and $K$ ($1 \leq N \leq 100, 0 \leq K \leq N \times (2N-1)$).
-
The $i$-th line of the next $K$ lines contains two integers $u_ i$ and $v_ i$, where $1\leq u_ i \neq v_ i \leq 2N$.
Output
Write out the result in the following format.
-
If you can find a required schedule, write out on the first line the string “YES”, on the second line the integer $P$ as the number of the derby matches at the final round; and then write out on the next (2$N$-1) groups of lines, each group consists of $N$ consecutive lines describing the schedule of one round: each line contains two integers $X$ and $Y$ which denotes a match between team $X$ and team $Y$.
-
Otherwise, write out on one line the string “NO”.
Sample Input 1 | Sample Output 1 |
---|---|
2 1 1 3 |
YES 1 1 2 3 4 1 4 2 3 1 3 2 4 |