#K83447. Generate Unique Rounds

    ID: 36199 Type: Default 1000ms 256MiB

Generate Unique Rounds

Generate Unique Rounds

Given a total number of available problems m and an integer k representing the number of problems required for a round, along with a list of m unique problem IDs, your task is to generate all possible unique rounds. Each round is a combination of k problem IDs, and the IDs within each round must be in ascending order. The rounds should be output in lexicographical order.

If k > m, then no valid round exists; in that case, output No valid rounds.

The number of rounds can be computed using the combinatorial formula: \( C(m,k)=\frac{m!}{k!(m-k)!} \).

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains two integers m and k separated by a space.
  • The second line contains m space-separated integers representing the problem IDs.

outputFormat

If valid rounds can be formed, output each round on a new line with the problem IDs separated by a single space. If no valid round exists (i.e. when k > m), output No valid rounds.

## sample
5 3
1 2 3 4 5
1 2 3

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

</p>