시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 512 MB | 44 | 19 | 12 | 34.286% |
A permutation of size n is a list of integers (p1, p2, ..., pn) from 1 to n such that each number appears exactly once.
The number of fixed points of a permutation is the number of indices i such that pi = i.
Given three numbers n, m, and k, find the kth lexicographically smallest permutation of size n that has exactly m fixed points (or print -1 if there are fewer than k permutations that satisfy the condition).
The single line of input contains three space-separated integers
n (1 ≤ n ≤ 50) m (0 ≤ m ≤ n) k (1 ≤ k ≤ 1018)
where n is the size of the permutations, m is the number of desired fixed points, and the output should be the kth lexicographically smallest permutation of the numbers 1 to n that has exactly m fixed points.
Output the desired permutation on a single line as a sequence of n space-separated integers, or output -1 if no such permutation exists.
3 1 1
1 3 2
3 2 1
-1
5 3 7
2 1 3 4 5