QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 2048 MB

#22847. 寻找递增子序列

Statistics

给定一个正整数 $N$ 和一个非负整数 $X$。

请判断是否存在一个长度为 $2N$ 的序列 $A = (A_1, A_2, \dots, A_{2N})$,同时满足以下所有条件:

  • 从 $1$ 到 $N$ 的每个整数在 $A$ 中恰好出现两次。
  • 序列 $(1, 2, \dots, N)$ 作为 $A$ 的子序列恰好出现 $X$ 次。换句话说,恰好有 $X$ 种选择下标 $1 \le i_1 < i_2 < \dots < i_N \le 2N$ 的方式,使得 $A_{i_j} = j$ $(1 \le j \le N)$。

如果存在这样的序列,请输出其中一个。如果存在多个满足条件的序列,输出任意一个即可。

输入格式

输入包含多组测试数据,格式如下:

$$ \begin{aligned} &T \\ &\mathrm{case}_1 \\ &\mathrm{case}_2 \\ &\vdots \\ &\mathrm{case}_T \end{aligned} $$

每组测试数据的格式如下:

$$ N \ X $$

第一行包含一个整数 $T$ $(1 \le T \le 2 \times 10^5)$,表示测试数据的组数。

对于每组测试数据,给定一个正整数 $N$ $(1 \le N \le 2 \times 10^5)$ 和一个非负整数 $X$ $(0 \le X \le 10^{18})$。

所有测试数据中 $N$ 的总和不超过 $2 \times 10^5$。

输出格式

对于每组测试数据,如果不存在满足条件的序列,输出一行 No。

否则,第一行输出 Yes,第二行输出 $2N$ 个整数 $A_1, A_2, \dots, A_{2N}$,表示一个满足条件的序列。

如果存在多个合法的序列,输出其中任意一个均可。

样例

输入格式 1

3
2 3
50 1000000000000000000
4 0

输出格式 1

Yes
1 2 1 2
No
Yes
4 4 3 3 2 2 1 1

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.