Universal Cup Judging System

Universal Cup

時間限制: 2 s 記憶體限制: 1024 MB 總分: 100 难度: [顯示]
统计

KamomeはShiratama風の絵を描くのが好きです。問題作成者は面倒くさがり屋なのでストーリーは省略して本題に入ります。Kamomeの絵は、$1 \sim 2n$ の順列である $p_1, p_2, \dots, p_{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$) が与えられ、順列の長さを表す。2行目には $2n$ 個の整数 $p_1, p_2, \dots, p_{2n}$ ($1 \le p_i \le 2n$, $1 < i < j \le 2n$ に対して $p_i \ne p_j$) が与えられ、順列を表す。

出力

各テストケースについて、順列をソートできない場合は NO と出力せよ。そうでなければ、3行を出力せよ。1行目は YES、2行目は整数 $k$ ($0 \le k \le 2n^2 + 2n$)、3行目は $k$ 個の整数 $a_1, a_2, \dots, a_k$ ($a_i \in \{1\} \cup \{2, 4, \dots, 2n\}$) を含む。$a_i = 1$ の場合は操作1を実行することを意味し、そうでない場合は $x = a_i$ として操作2を実行することを意味する。

操作1は最大 $2n$ 回、操作2は最大 $2n^2$ 回までしか使用できないことに注意せよ。複数の可能な答えがある場合は、そのうちのどれを出力してもよい。

入出力例

入力 1

3
2
1 3 4 2
2
2 4 1 3
3
1 2 4 3 5 6

出力 1

NO
YES
2
2 1
YES
7
2 4 1 6 1 2 4

注記

テストケース2における順列の変形は以下の通りである: $[2, 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.