| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 64 | 45 | 38 | 74.510% |
An array $a$ of size $n$ is considered $k$-regular if every subarray of $a$ of size $k$ contains all integers from $1$ to $k$, inclusive.
For example, $a = [2, 1, 3, 2]$ is $3$-regular, because its two subarrays of size $3$ are $[2, 1, 3]$ and $[1, 3, 2]$, each of which contains all integers from $1$ to $3$. On the other hand, $a = [1, 2, 3, 4]$ is not $3$-regular because the subarray $[2, 3, 4]$ of size $k=3$ does not contain $1$.
Your task is to find a $k$-regular array $a$ of size $n$ such that the sum of its elements is maximized.
The first line of the input contains a single integer $t$ ($1 \le t \le 10^4$) --- the number of test cases. The description of the test cases follows.
Each test case consists of a single line containing two integers $n$ and $k$ ($1 \le k \le n \le 2\cdot 10^5$) --- the desired size of the array $a$, and the parameter $k$ described above.
It is guaranteed that the sum of $n$ across all test cases is at most $2\cdot 10^5$.
For each test case, output a single line containing $n$ integers $a_1, a_2, \cdots a_n$ --- a $k$-regular array $a$ of size $n$ with maximal sum.
If there are multiple solutions, you may print any.
4 4 3 5 1 3 2 1 1
3 1 2 3 1 1 1 1 1 2 1 2 1
In the first sample case, the array $a = [3, 1, 2, 3]$ is $3$-regular because its two subarrays of size $3$ are $[3, 1, 2]$ and $[1, 2, 3]$, each of which contains all integers from $1$ to $3$. The sum of this array is $3 + 1 + 2 + 3 = 9$, which we can show is maximal for this $n$ and $k$.
In the second sample case, each subarray of size $1$ must contain $1$, and therefore, the array must consist only of ones.