QOJ.ac

QOJ

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

#18302. Remix

統計

You are given a multiset $S$ consisting of $n$ integers. You should perform the following three-step operation some number of times until a single integer remains in $S$.

  1. Choose a multiset $T$ such that $T$ is a sub-multiset of $S$ and $|T| \ge 2$.
  2. Erase the elements of $T$ from $S$.
  3. Insert the value $\max(T) - \min(T)$ into $S$.

Find a sequence of operations that maximizes the integer left in $S$.

Input

The first line contains a single integer $n$ ($2 \le n \le 10^5$).

The second line contains $n$ integers $S_1, S_2, \ldots, S_n$ ($0 \le S_i \le 10^5$).

Output

On the first line, print a single integer $k$, the number of operations ($1 \le k \le n - 1$).

On each of the next $k$ lines, print an integer $m$, the size of the chosen multiset $T$, followed by $m$ integers $T_1, T_2, \ldots, T_m$, the multiset itself, in any order ($2 \le m \le n$).

Note that the operations are performed in the same order they are listed. So, for each operation, $T$ must be a sub-multiset of $S$ when all the preceding operations are performed.

Examples

Input 1

7
33 24 63 48 97 90 93

Output 1

4
3 33 93 90
2 63 60
2 48 24
3 97 24 3

Note

In the example, we can perform the following operations:

Chosen $T$ New $S$
$0$ $\{24, 33, 48, 63, 90, 93, 97\}$
$1$ $\{33, 90, 93\}$ $\{24, 48, 60, 63, 97\}$
$2$ $\{60, 63\}$ $\{3, 24, 48, 97\}$
$3$ $\{24, 48\}$ $\{3, 24, 97\}$
$4$ $\{3, 24, 97\}$ $\{94\}$

The underlined values in $S$ denote the inserted integers. After the fourth operation, $S$ is reduced to a single integer value of $94$. It can be shown that no other sequence of operations results in a larger value.

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.