QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 10

#5238. Photograph [C]

Statistiques

The graduates of the Byteotian Technical School (BST) have gathered in the square in front of the school to take a commemorative photo. They have all lined up in a row, with positions numbered from $1$ to $n$ from left to right, where $n$ is the number of graduates this year.

The photographer has decided to rearrange the people in the photo to order them by height in ascending order. The shortest person should be at the leftmost position, and the tallest at the rightmost position. Fortunately, no two graduates have the same height.

To avoid confusion, the rearrangement will take place in an orderly fashion. In one round, the photographer will call out a list of position numbers. The people at these positions will step out of the line to the center of the square, in the order the positions were called. Then, the photographer will repeat the same list of numbers. The people from the center of the square will return to the positions in the order they were called, but in the reverse order of how they left the line.

We want to arrange all graduates in ascending order in the minimum possible number of rounds. Your task is to plan the rearrangement. Provide the photographer with the lists of position numbers that should be called in each round.

Input

The first line of input contains a single integer $n$ ($1 \le n \le 3000$), representing the number of graduates.

The next $n$ lines of input contain a sequence of integers $h_1, h_2, \dots, h_n$ ($1 \le h_i \le 3000$), one number per line, describing the heights in millimeters of the people standing in the row, from left to right. All heights are distinct.

Output

The first line of output should contain a single integer $r$, representing the minimum number of rounds needed to arrange everyone in ascending order of height.

The next $2r$ lines should contain the description of these rounds. The first line of the description for the $i$-th round should contain a single integer $p_i$ ($1 \le p_i \le n$), representing the number of position numbers called in the $i$-th round. The second line of the description for the $i$-th round should contain $p_i$ position numbers in the order they are called. Position numbers within a single round cannot repeat.

If there are multiple possible solutions with the same (minimum) number of rounds, output any one of them.

Examples

Input 1

5
1670
2011
1560
1232
1447

Output 1

1
5
2 1 3 4 5

Note

In the first example, one round is sufficient. All graduates with heights $[2011, 1670, 1560, 1232, 1447]$ step out to the center of the square. Then, these people return to positions $2, 1, 3, 4,$ and $5$ in reverse order. The final order is $[1232, 1447, 1560, 1670, 2011]$, which is the ascending order.

Input 2

6
1556
1449
1863
2014
1333
1220

Output 2

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

Note

In the second example, we can finish in two rounds, and it can be proven that it is impossible to finish in fewer. The order of heights after the first round is $[1556, 1449, 1333, 1220, 1863, 2014]$, and after the second round it is $[1220, 1333, 1449, 1556, 1863, 2014]$.

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.