#P7931. [COCI 2021/2022 #1] Volontiranje

    ID: 9003 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>2021Special JudgeCOCI(克罗地亚)

[COCI 2021/2022 #1] Volontiranje

Problem Description

Given a permutation pp of 1n1 \sim n, please take as many pairwise disjoint increasing subsequences as possible, where each subsequence has length equal to the LIS length of the original permutation, and construct one valid solution.

Input Format

The first line contains an integer nn.

The next line contains nn integers pip_i.

Output Format

On the first line, output the number of increasing subsequences you choose and their length.

On the next several lines, output several integers per line, representing the indices of the elements in one increasing subsequence.

You may output the increasing subsequences in any order.

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

Hint

Constraints

For all testdata, 1n1061 \le n \le 10^6, 1pin1 \le p_i \le n.

Subtask Constraints Score
11 n15n \le 15 1010
22 n103n \le 10^3 4040
33 No additional constraints 6060

Notes

The total score for this problem is 110110 points.

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

A checker.cpp is provided in the additional files.

Translated by ChatGPT 5