QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#9937. 海棠与三角形

统计

给定两个整数 $n, m$,构造一个长度为 $n$ 的排列,满足以下条件:

  • 恰好有 $m$ 个长度为 3 的子区间,使得这些子区间内的数字构成一个(非退化的)三角形。

输入格式

每个测试点包含多个测试用例。第一行包含一个整数 $T$ ($1 \le T \le 10^5$),表示测试用例的数量。接下来是各测试用例的描述。

每个测试用例仅占一行,包含两个整数 $n$ 和 $m$ ($3 \le n \le 3 \times 10^5, 0 \le m \le n - 2$),分别表示排列的长度和目标子区间的数量。

保证所有测试用例中 $n$ 的总和不超过 $3 \times 10^5$。

输出格式

对于每个测试用例,输出一行。

如果存在这样的排列,输出 $n$ 个整数 $p_i$,表示你构造的排列。否则,输出 “-1”。

样例

输入格式 1

5
4 0
4 1
4 2
6 2
11 5

输出格式 1

3 1 2 4
1 2 3 4
-1
5 2 4 3 1 6
11 2 10 3 1 6 8 4 5 7 9

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.