Universal Cup Judging System

Universal Cup

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

문제

Kamome은 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$, $1 < 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$를 선택함을 의미합니다.

참고로 연산 1을 $2n$번 초과하거나 연산 2를 $2n^2$번 초과하여 사용할 수 없습니다. 여러 개의 가능한 답이 있다면 그중 하나를 출력해도 됩니다.

예제

standard input standard output
3 NO
2
1 3 4 2
2 YES
2 4 1 3 2
3 2 1
1 2 4 3 5 6 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.