Universal Cup Judging System

Universal Cup

Límite de tiempo: 3.0 s Límite de memoria: 1024 MB Puntuación total: 100 Dificultad: [mostrar] Hackeable ✓
Estadísticas

小青鱼有两个队列 $Q_1$ 和 $Q_2$,大小分别为 $m$ 和 $m + 1$。初始时,两个队列均为空。

他需要同时向两个队列中依次添加若干个元素。具体来说,他需要确定一个序列 $c_1, c_2, \dots, c_k$,并按顺序将 $c_1, c_2, \dots, c_k$ 添加到两个队列中。

当向队列中添加一个元素时,如果该元素已经存在于队列中,则什么也不会发生;否则,该元素会被添加到队列的末尾。如果队列中的元素数量超过了其容量,则队列头部的元素会被弹出。

现在,小青鱼给出了这两个队列的最终状态。这两个队列中的元素从队首到队尾依次为 $a_1, a_2, \dots, a_m$ 和 $b_1, b_2, \dots, b_{m+1}$。

小青鱼想知道是否可以构造一个满足该条件的序列 $c$,且序列的长度不超过 $50 \cdot m$。他知道在题目的限制下,如果存在解,其长度一定不会超过 $50 \cdot m$。

输入格式

输入文件包含多个测试用例。输入的第一行包含一个整数 $T$ ($T \ge 1$),表示测试用例的数量。对于每个测试用例:

  • 第一行包含一个整数 $m$ ($m \ge 4$),表示两个队列的大小。
  • 下一行包含 $m$ 个整数 $a_1, a_2, \dots, a_m$ ($1 \le a_i \le 10^9$)。保证 $a$ 中的元素互不相同。
  • 接下来的一行包含 $m + 1$ 个整数 $b_1, b_2, \dots, b_{m+1}$ ($1 \le b_i \le 10^9$)。保证 $b$ 中的元素互不相同。

保证所有测试用例中 $m$ 的总和不超过 $2 \times 10^4$。

输出格式

对于每个测试用例,如果无法构造该序列,输出单行 "No"。

否则,输出的第一行应包含单词 "Yes"。接着,下一行应包含一个整数 $k$ ($1 \le k \le 50 \cdot m$),表示序列的长度。

然后输出一行,包含 $k$ 个整数 $c_1, c_2, \dots, c_k$ ($1 \le c_i \le 10^9$),表示构造的序列。

如果有多个可能的解,你可以输出其中任意一个。

样例

输入样例 1

3
4
2 3 4 5
1 2 3 4 5
5
1 3 5 7 9
2 4 6 8 10 11
4
100 200 300 400
100 200 300 400 500

输出样例 1

Yes
5
1 2 3 4 5
No
Yes
9
100 200 300 400 500 100 200 300 400

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1290EditorialOpenEditorial for Problem #14015Cybher2026-03-18 13:41:45View

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.