407425: GYM102788 C Magic football

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Magic footballtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Magic football is very popular in the Magic Land. In this game, the only way to hit the ball is using your magic skills. Unfortunately, players become exhausted after their magic efforts so they have to be substituted quite often. According to the rules of the game, each combination of players can play for exactly one minute. Each time only one player is substituted. It is prohibited to repeat the same team composition twice during the game.

The team from the Emerald City has $$$n$$$ players. According to the rules of magic football, $$$k$$$ players must be present in the field at any given moment. The game lasts $$$t$$$ minutes.

Example: let $$$n = 5, k = 3$$$; in this case, $$$10$$$ different team composition options are possible.

Write a program that will either generate a substitution schedule based on the given team size $$$n$$$, number of players in the field $$$k$$$, and game duration $$$t$$$ minutes or conclude that there is no suitable solution.

If there are several suitable schedule options, any one of them is regarded as a right solution.

Players are numbered $$$1$$$ to $$$n$$$.

Input

The input file contains three positive integers $$$n$$$, $$$k$$$, and $$$t$$$ ($$$1 \le k \le n, 1 \le t \le 10^5$$$) (separated by spaces).

Output

The first line of the output file must contain either a value of $$$t$$$ if there is a suitable solution or $$$0$$$ if there is no solution.

If there is a solution to the problem, the first line is followed by $$$t$$$ lines, each one describing the composition of the team. Such lines contain $$$k$$$ player numbers (separated by spaces). Player numbers are sorted strictly in the ascending order. Each team composition option can only be used once. Two successive lines must differ by one player only.

ExamplesInput
5 3 10
Output
10
1 2 3 
1 3 4 
2 3 4 
1 2 4 
1 4 5 
2 4 5 
3 4 5 
1 3 5 
2 3 5 
1 2 5 
Input
2 1 3
Output
0

加入题单

算法标签: