Universal Cup Judging System

Universal Cup

时间限制: 2 s 内存限制: 1024 MB 总分: 100 难度: [显示]
统计

题目描述

Kamome 是 Shiratama 的忠实粉丝,他想创作一些 Shiratama 风格的画作。 嗯,出题人太懒了,不想写故事,让我们直接进入问题。 Kamome 的画作可以抽象成一个 $p_1, p_2, \dots, p_{2n}$ 的排列,其中 $1 \sim 2n$ 是一个排列。你需要通过执行不超过 $2n$ 次操作 1 和不超过 $2n^2$ 次操作 2 来对 $p$ 进行排序。

  • 操作 1:对于所有奇数 $i = 1, 3, \dots, 2n-1$,同时交换 $p_i$ 和 $p_{i+1}$。
  • 操作 2:Kamome 选择一个偶数 $i$ ($1 \le i \le 2n$) 并交换 $p_i$ 和 $p_{i+1}$。注意我们认为 $p_{2n+1} = p_1$。

然而,有时使用上述操作无法对这个排列进行排序,如果是这样,请报告。

输入格式

每个测试包含多组测试数据。 第一行包含一个整数 $t$ ($1 \le t \le 10^5$),表示测试数据的组数。 接下来是测试数据的描述。

每组测试数据的第一行包含一个整数 $n$ ($1 \le n \le 100$, $\sum n^2 < 10^6$),表示排列的长度。 第二行包含 $2n$ 个整数 $p_1, p_2, \dots, p_{2n}$ ($1 \le p_i \le 2n$, $p_i \ne p_j$ 对于 $1 < i < j \le 2n$),表示排列。

输出格式

对于每组测试数据,如果无法对排列进行排序,输出一个单词 NO。 否则,你的输出包含三行。第一行包含一个单词 YES,第二行包含一个整数 $k$ ($0 \le k \le 2n^2 + 2n$),第三行包含 $k$ 个整数 $a_1, a_2, \dots, a_k$ ($a_i \in \{1\} \cup \{2, 4, \dots, 2n\}$)。如果 $a_i = 1$,则表示执行操作 1;否则表示执行操作 2 并选择 $x = a_i$。

注意,你不能使用超过 $2n$ 次操作 1 和 $2n^2$ 次操作 2。 如果有多个可能的答案,你可以输出任意一个。

样例

样例 1

输入
3
2
1 3 4 2
2
2 4 1 3
3
1 2 4 3 5 6
输出
NO
YES
2
2 1
YES
7
2 4 1 6 1 2 4

说明

对于样例 2,排列的变化如下所示: $[2, 4, 1, 3] \to [2, 1, 4, 3] \to [1, 2, 3, 4]$

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.