P29744 [洛谷] [COCI2021-2022#1] Volontiranje
提高+
题目描述

Problem Description

Given a permutation \( p \) of \( 1 \sim n \), extract as many non-overlapping increasing subsequences as possible, each of which has the length of the Longest Increasing Subsequence (LIS) of the original permutation, and construct a solution.

Input Format

The first line contains an integer \( n \).

The next line contains \( n \) integers \( p_i \).

Output Format

The first line should output the number of increasing subsequences you have chosen and their length.

The following lines, each containing several integers, represent the indices of the elements in each increasing subsequence.

You can output the chosen increasing subsequences in any order.

Sample Input and Output

Sample Input #1

3
1 2 3

Sample Output #1

1 3
1 2 3

Sample Input #2

4
4 3 2 1

Sample Output #2

4 1
1
2
3
4

Sample Input #3

7
2 1 6 5 7 3 4

Sample Output #3

2 3
1 3 5
2 6 7

Notes

Data Range

For all data, \( 1 \le n \le 10^6 \), \( 1 \le p_i \le n \).

Subtask Data Range Score
$1$ $n \le 15$ $10$
$2$ $n \le 10^3$ $40$
$3$ No special restrictions $60$

Notes

This problem is worth a total of $110$ points.

This problem is translated from the Croatian Open Competition in Informatics 2021/2022 Contest #1 T5 Volontiranje.

A checker.cpp is provided in the additional files.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1 2 3
样例输出
1 3 1 2 3