题目描述
Problem Description
Given positive integers $N$ and $K$.
An integer sequence of length $NK$ where each integer between $1$ and $N$ appears exactly $K$ times is called a good sequence.
Let $S$ be the number of good sequences. Find the $\operatorname{floor}((S+1)/2)$-th good sequence in lexicographical order. Here, $\operatorname{floor}(x)$ represents the largest integer not exceeding $x$.
What is lexicographical order for sequences? A sequence $S = (S_1, S_2, \ldots, S_{|S|})$ is smaller in lexicographical order than a sequence $T = (T_1, T_2, \ldots, T_{|T|})$ if either of the following holds:
- $ |S| < |T| $ and $(S_1, S_2, \ldots, S_{|S|}) = (T_1, T_2, \ldots, T_{|S|})$.
- There exists an integer $1 \leq i \leq \min\{|S|, |T|\}$ such that both of the following are true:
- $(S_1, S_2, \ldots, S_{i-1}) = (T_1, T_2, \ldots, T_{i-1})$
- $ S_i $ is smaller than $ T_i $ (as a number).
Input Format
The input is given from the standard input in the following format:
$ N $ $ K $
Output Format
Output the resulting sequence with elements separated by spaces.
Sample Input and Output
Sample Input #1
2 2
Sample Output #1
1 2 2 1
Sample Input #2
1 5
Sample Output #2
1 1 1 1 1
Sample Input #3
6 1
Sample Output #3
3 6 5 4 2 1
Sample Input #4
3 3
Sample Output #4
2 2 2 1 3 3 3 1 1
Notes/Hints
Constraints
- $1 \leq N \leq 500$
- $1 \leq K \leq 500$
- All values in the input are integers.
Sample Explanation 1
The good sequences are as follows:
- $ (1,1,2,2) $
- $ (1,2,1,2) $
- $ (1,2,2,1) $
- $ (2,1,1,2) $
- $ (2,1,2,1) $
- $ (2,2,1,1) $
Thus, the $3$-rd sequence in lexicographical order, $ (1,2,2,1) $, is the answer.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分