QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#9641. Two permutations

统计

题目描述

小 $D$ 有一个长度为 $2n$ 的序列 $a_1, a_2, a_3, \dots, a_{2n}$,其中 $1 \sim n$ 的每一个数在这个序列中都恰好出现了两次。并且 $a_1, a_2, a_3, \dots, a_n$ 构成了一个 $1 \sim n$ 的排列。

小 $D$ 记数字 $i$ 的两个出现位置为 $x_i, y_i$ 满足 $1 \le x_i \le n < y_i \le 2n$。

小 $D$ 还定义了一个集合运算 $\oplus$ 如下。

$A \oplus B = \{x \mid [x \in A] + [x \in B] = 1\}$

定义 $f(S)$ 表示的是 $S$ 中最小没有出现过的正整数。

现在小 $D$ 会告诉你 $v_i = f(\{a_{x_i}\} \oplus \{a_{x_i+1}\} \oplus \cdots \oplus \{a_{y_i}\})$。他希望你根据序列 $v$ 构造一个序列 $a$ 使其符合条件。

输入格式

第一行为一个正整数 $T$,表示数据组数。

接下来 $2T$ 行,描述 $T$ 组数据。

每组数据的第一行为一个正整数 $n$,表示序列中出现的数字数量。

每组数据的第二行为 $n$ 个正整数 $v_1, v_2, v_3, \dots, v_n$,表示求出来的值。

输出格式

对于所有的 $T$ 组数据输出答案。

每组数据的第一行为一个字符串 Yes 或者是 No,表示是否有解。

如果有解那么在第二行输出 $2n$ 个正整数 $a_1, a_2, a_3, \dots, a_{2n}$,表示你构造出的序列,如果存在多组符合条件的构造随便给出一组即可

样例

样例输入
2
4
1 2 2 2
3
3 2 1
样例输出
Yes
3 2 4 1 4 2 3 1
No

数据范围

子任务编号 $n \le$ $\sum n \le$ 特殊性质 分数
$1$ $5$ $50$ $ $ $10$
$2$ $10$ $100$ $10$
$3$ $2 \times 10^5$ $2 \times 10^6$ $A$ $15$
$4$ $2 \times 10^5$ $2 \times 10^6$ $B$ $15$
$5$ $2 \times 10^5$ $2 \times 10^6$ $ $ $50$

特殊性质 $A$:满足 $v_i \le 4$。

特殊性质 $B$:满足 $v_{v_i} = v_i$。

对于 $100\%$ 的数据,满足 $1 \le T \le 10$,$1 \le n \le 2 \times 10^5$,$1 \le \sum n \le 2 \times 10^6$,$1 \le v_i \le n$。

下发文件的答案文件中并不存在构造方案。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.