

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 700 点
問題文
(1,\ldots,N) の順列 P=(P_1,\ldots,P_N) の要素のうち,以下の条件を満たすものを良い要素と呼びます.
- その要素は P の最長増加部分列にも最長減少部分列にも含まれうる.
整数 N,K が与えられます. 良い要素がちょうど K 個であるような (1,\ldots,N) の順列 P が存在するか判定し,存在するならば一つ求めてください.
T 個のテストケースについて答えてください.
制約
- 入力される数値は全て整数
- 1 \leq T \leq 2\times 10^5
- 1 \leq N \leq 2\times 10^5
- 0\leq K \leq N
- 全てのテストケースにわたる N の総和は 2\times 10^5 を超えない.
入力
入力は以下の形式で標準入力から与えられる.
T \mathrm{case}_1 \vdots \mathrm{case}_T
各テストケースは以下の形式で与えられる.
N K
出力
T 行出力せよ.
i 行目には,i 番目のテストケースについて,条件を満たす順列が存在しない場合,-1
を出力せよ.
存在する場合,その内一つを以下の形式で出力せよ.
P_1 \ldots P_N
条件を満たす解が複数存在する場合,どれを出力しても正解とみなされる.
入力例 1
3 1 0 7 2 2 1
出力例 1
-1 7 4 6 2 3 1 5 -1
2 番目のテストケースでは,P_4=2 と P_5=3 が良い要素です.
実際,P の最長増加部分列として, (2,3,5) が考えられます.また,P の最長減少部分列として, (7,6,2,1) や (7, 6, 3, 1) が考えられます.
よって,この出力例において 2 と 3 は良い要素です.その他の要素は良い要素ではないので,この出力は条件を満たします.
1, 3 番目のテストケースでは,条件を満たす順列は存在しません.よって,-1
を出力します.
Score : 700 points
Problem Statement
Among the elements of a permutation P=(P_1,\ldots,P_N) of (1,\ldots,N), those that satisfy the following condition are called good elements:
- The element can be included in both a longest increasing subsequence and a longest decreasing subsequence of P.
You are given integers N and K. Determine whether there exists a permutation P of (1,\ldots,N) such that there are exactly K good elements, and if it exists, find one.
Answer for T test cases.
Constraints
- All input values are integers
- 1 \leq T \leq 2\times 10^5
- 1 \leq N \leq 2\times 10^5
- 0\leq K \leq N
- The sum of N over all test cases does not exceed 2\times 10^5.
Input
The input is given from Standard Input in the following format:
T \mathrm{case}_1 \vdots \mathrm{case}_T
Each test case is given in the following format:
N K
Output
Output T lines.
For the i-th line, if there does not exist a permutation satisfying the condition for the i-th test case, output -1
.
If it exists, output one of them in the following format:
P_1 \ldots P_N
If there are multiple solutions satisfying the condition, any of them will be accepted.
Sample Input 1
3 1 0 7 2 2 1
Sample Output 1
-1 7 4 6 2 3 1 5 -1
In the 2-nd test case, P_4=2 and P_5=3 are good elements.
Indeed, (2,3,5) is a longest increasing subsequence of P. Also, (7,6,2,1) and (7, 6, 3, 1) are longest decreasing subsequences of P.
Therefore, in this sample output, 2 and 3 are good elements. The other elements are not good elements, so this output satisfies the condition.
In the 1-st and 3-rd test cases, there does not exist a permutation satisfying the condition. Thus, output -1
.