NMK
Time limit2sMemory limit128 MB
Construct a permutation of 1..N whose longest increasing subsequence is exactly M and longest decreasing subsequence is exactly K, or report impossible.
- Level
Medium6 of 10
- Topics
- Combinatorics, Greedy, Math, Array
- Solved
- No attempts yet
Problem
Use each integer from 1 through N exactly once to form a sequence.
The sequence must have longest strictly increasing subsequence length exactly M, and longest strictly decreasing subsequence length exactly K.
Print one sequence satisfying these conditions.
Input
The first line contains three integers N, M, and K.
Output
Print a sequence satisfying the conditions on one line, with numbers separated by spaces.
If no such sequence exists, print -1.
Constraints
1 <= N <= 5001 <= M, K <= N