Public Judge

pjudge

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100 Hackable ✓

#21795. 【NOIP Round #6】Sorting

Statistiques

Today is YQH's birthday, and she received a permutation of $1 \sim n$ as a gift.

YQH is a perfectionist, and she wants to sort this permutation in ascending order. Specifically, she can perform the following operation:

  • Divide the range $[1, n]$ into several segments, say $m$ segments: $[l_1, r_1], [l_2, r_2], \dots, [l_m, r_m]$, where $l_1 = 1, r_m = n, l_{i+1} = r_i + 1$, and $l_i \le r_i$.
  • If the original permutation is $a_{1, \dots, n}$, the permutation becomes $a_{l_m}, a_{l_m+1}, \dots, a_{r_m}, a_{l_{m-1}}, a_{l_{m-1}+1}, \dots, a_{r_{m-1}}, \dots, a_{l_1}, a_{l_1+1}, \dots, a_{r_1}$. That is, treat each segment as a single block and reverse the order of these blocks in the permutation.

YQH wants to sort the sequence in ascending order using as few operations as possible. However, she is not very clever, so she has asked for your help. Note that you do not need to find the minimum number of operations.

Input

The first line contains a positive integer $n$, representing the length of the permutation.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$, representing the permutation YQH received. It is guaranteed that $a_{1, \dots, n}$ is a permutation of $1 \sim n$.

Output

The first line contains an integer $p$, representing the number of operations you perform.

The next $p$ lines each start with an integer $m$, representing that you divide the permutation into $m$ segments for this operation. This is followed by $m$ integers $len_i$, representing the length of the $i$-th segment (i.e., $len_i = r_i - l_i + 1$). You must ensure that $\sum_{i=1}^m len_i = n$.

Examples

Input 1

4
3 1 2 4

Output 1

2
2 3 1 
3 1 1 2

Note 1

In the first operation, the sequence is divided into $[3, 1, 2], [4]$, and after the operation, it becomes $[4, 3, 1, 2]$.

In the second operation, the sequence is divided into $[4], [3], [1, 2]$, and after the operation, it becomes $[1, 2, 3, 4]$.

Input 2

6
6 5 4 3 2 1

Output 2

1
6 1 1 1 1 1 1

Note 2

In the first operation, the sequence is divided into $[6], [5], [4], [3], [2], [1]$, and after the operation, it becomes $[1, 2, 3, 4, 5, 6]$.

Input 3

1
1

Output 3

0

Note 3

The original sequence is already sorted, so no operations are needed.

Constraints

This problem uses scoring parameters for evaluation. Specifically, for each test case, we have scoring parameters $p_0, p_1, p_2, p_3, p_4$, where $p_i \ge p_{i+1}$. If your number of operations is $p$, your score for that test case is:

$$ \frac{[p\le p_0]+\sum_{i=0}^3 \max(\frac{p_i-\max(p,p_{i+1})}{p_i-p_{i+1}},0)}{5} $$

where $0/0=1$ and $-1/0=-\infty$.

For each subtask, if the subtask score is $w$, your score is the minimum score among all test cases in that subtask multiplied by $w$.

  • Subtask 1: 10 pts, $n \le 8, p_0 = p_1 = p_2 = p_3 = p_4 = 10^6$.
  • Subtask 2: 20 pts, $n \le 200, p_0 = p_1 = p_2 = p_3 = p_4 = 40000$.
  • Subtask 3: 70 pts, $n = 20000, p_0 = 1000, p_1 = 500, p_2 = 240, p_3 = 140, p_4 = 90$.

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.