QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 1024 MB Toplam puan: 100 Zorluk: [göster]

#14979. Shiratama

İstatistikler

Kamome 作為 Shiratama 嘅忠實粉絲,正嘗試創作一啲 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 \le 10^6$),代表排列嘅長度參數。

第二行包含 $2n$ 個整數 $p_1, p_2, \dots, p_{2n}$($1 \le p_i \le 2n$,對於 $1 \le i < j \le 2n$ 有 $p_i \ne p_j$),代表呢個排列。

輸出格式

對於每組測試數據,如果冇辦法將個排列排好序,輸出一個單詞 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。

如果有多個可能嘅答案,你可以輸出其中任意一個。

範例

輸入

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, \underline{4, 1}, 3] \to [\underline{2, 1}, \underline{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.