#K60707. Tournament Scheduling

    ID: 31146 Type: Default 1000ms 256MiB

Tournament Scheduling

Tournament Scheduling

You are given a number n representing the number of players in a tournament. Your task is to schedule a round-robin tournament where every player plays in every round and no pair of players plays against each other more than once. The tournament schedule is only possible if n is even and within the range \(2 \le n \le 100\). Otherwise, output "NO".

If the tournament is possible, the schedule should have \(n-1\) rounds. In each round, there will be \(\frac{n}{2}\) pairs. Each match is represented by two integers, the numbers of the players in that match. The output should start with "YES", and then each subsequent line should list the pairs for each round, with a single space separating each number.

For example, when n = 4, a valid output is:

YES
1 4 2 3
1 3 4 2
1 2 3 4

And when n = 3 (an odd number), the output should be "NO".

inputFormat

The input consists of a single integer n read from standard input, where \(2 \le n \le 100\). If n is not even or not in the range, the tournament scheduling is not possible.

outputFormat

If it's possible to schedule the tournament, output "YES" followed by \(n-1\) rounds. Each round is printed in a new line with \(\frac{n}{2}\) pairs of players separated by spaces. Otherwise, output "NO".

## sample
4
YES

1 4 2 3 1 3 4 2 1 2 3 4

</p>