QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18288. Book Sorting

統計

In the KSA library, $N$ books are placed in a straight line. The heights of the books from left to right form a permutation $A = (A_1, A_2, \cdots, A_N)$ of length $N$. In other words, $A$ is a sequence in which each integer from $1$ to $N$ appears exactly once.

Hanbumi, a library club member, wants to sort the books in ascending order by repeating the following operation $0$ or more times.

  • Select two consecutive books and move them to the leftmost position while maintaining their order.

Find a sequence of operations that sorts the permutation in at most $N^2$ operations.

Input

The first line contains an integer $N$.

The second line contains $N$ space-separated integers $A_1, A_2, \cdots, A_N$.

Output

On the first line, print YES if there is a way to sort the books in ascending order using at most $N^2$ operations, and NO otherwise.

If there is such a way, let the required number of operations be $k$. On the second line, print integer $k$. It must satisfy $0 \le k \le N^2$, but it is not necessary to minimize $k$.

If $k > 0$, print $k$ space-separated integers $x_1, x_2, \cdots, x_k$ on the third line. $x_i$ means that in the $i$-th operation, the $x_i$-th book and the $x_i+1$-th book from the left are selected and moved to the leftmost position.

If there are multiple solutions, print any of them.

Constraints

  • $2 \le N \le 100$
  • $1 \le A_i \le N$
  • If $i \ne j$, then $A_i \ne A_j$

Scoring

No. Points Constraints
1 35 There exists a way to sort the books in ascending order
2 65 No additional constraints

Examples

Input 1

5
1 2 4 5 3

Output 1

YES
4
4 3 4 3

Input 2

3
3 2 1

Output 2

NO

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.