P28258 [洛谷] Thrombocytes and Coagulation Factors
普及+
题目描述

Background

In order to repair wounds quickly, thrombocytes are transporting coagulation factors. They are discussing how to distribute them, and since they are so adorable, they have asked you to solve this problem.

Problem Description

Thrombocytes have two types of containers. The first type can only contain the same type of coagulation factor, and the second type can contain each type of coagulation factor at most once. For convenience, thrombocytes want to use the same type of container to hold all coagulation factors.

In other words, divide $n$ positive integers $a_1$ to $a_n$ into some disjoint sets $S_1$ to $S_m$, satisfying one of the following conditions:
1. For all $a_i, a_j \in S_k, k \in [1, m]$, $a_i = a_j$.
2. For all $a_i, a_j \in S_k, k \in [1, m], i \neq j$, $a_i \neq a_j$.

Since there are relatively few thrombocytes, you need to put all coagulation factors into as few containers as possible. They want to know how to partition to minimize the total number of containers.

Input Format

The first line contains a positive integer $n$, representing the number of coagulation factors.

The second line contains $n$ positive integers $a_i$, representing the types of coagulation factors.

Output Format

The first line contains two positive integers, the first representing the minimum number of containers $m$, and the second representing the type of container used ($1$ or $2$).

The next $m$ lines, each starting with a positive integer $c_i$ representing the number of coagulation factors in this container, followed by $c_i$ numbers representing the types of coagulation factors in this container.

Output any valid optimal solution, the order of output is not restricted.

Sample Input and Output

Sample Input #1

7
1 2 3 5 4 4 4

Sample Output #1

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

Sample Input #2

3
20181110 20181111 20181111

Sample Output #2

2 1
1 20181110
2 20181111 20181111

Sample Input #3

3
20181110 20181111 20181111

Sample Output #3

2 2
2 20181110 20181111
1 20181111

Sample Input #4

5
3 2 3 2 3

Sample Output #4

2 1
3 3 3 3
2 2 2

Notes

$1 \le n \le 1000, \ 1 \le a_i \le 10^9$.

Sample Explanation

Sample #1:

Using the second type of container, place $\{4\}$, $\{3,1,2,4,5\}$, and $\{4\}$. This is a feasible optimal solution. Changing the order of the three containers or the order of the five coagulation factors in container 2 can yield other optimal solutions.

Sample #2/3:

These two samples have the same input and can use either the first or the second type of container.

The outputs for these two samples are feasible optimal solutions. Changing the order can yield other optimal solutions.

Sample #4:

Using the first type of container, place $\{3,3,3\}$ and $\{2,2\}$. This is a feasible optimal solution. Changing the order of the two containers can yield another optimal solution.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
7 1 2 3 5 4 4 4
样例输出
3 2 1 4 5 3 1 2 4 5 1 4