#P9394. 白鹭兰

    ID: 10288 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>洛谷原创Special JudgeO2优化洛谷月赛

白鹭兰

Problem Description

There are many legends about Martians, such as their DNA being very complex, or that they have tens of thousands of fingers, and so on, but none of these have been confirmed. Another unconfirmed legend is that Martians are very good at solving OI problems.

To verify this last legend, people on Earth gave an OI problem to an alien traveler from Mars:

Given a connected undirected graph G=(V,E)G=(V,E) with nn vertices and mm edges, find the minimum kk such that there exists a partition of the vertex set V1,,VtV_1,\ldots,V_t satisfying:

  • 1xt\forall 1\leq x\leq t, the induced subgraph of i=1xVi\bigcup_{i=1}^x V_i is connected;

  • 1xt\forall 1\leq x\leq t, the induced subgraph of i=xtVi\bigcup_{i=x}^t V_i is connected;

  • 1xt\forall 1\leq x\leq t, Vxk|V_x|\leq k.

Note that, as a partition, it must also satisfy i=1tVi=V\bigcup_{i=1}^t V_i=V, ViVj= (ij) V_i\cap V_j=\varnothing\ (\forall i\neq j), and all ViV_i are non-empty.

Output the minimum kk and a corresponding partition.

Goodbye, You're Martian. Now you need to finish this problem and prove the wisdom of Martians.

Input Format

The first line: two integers n,mn,m, representing the number of vertices and edges of graph GG.

The next mm lines: each line contains two integers x,yx,y, representing an undirected edge connecting vertices x,yx,y.

Output Format

The first line: two integers kmin,tk_{min},t, representing the minimum kk and the size of the corresponding partition.

The next tt lines: on the ii-th line, first an integer sis_i, representing the size of ViV_i, followed by sis_i integers representing the elements of ViV_i.

If there are multiple valid partitions, you may output any one of them. Note that you do not need to minimize tt.

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

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

Hint

[Sample Explanation]

In the figure below, V1,,V5V_1,\ldots,V_5 are the red / orange / green / blue / purple vertex sets, respectively. You can verify that they satisfy the conditions.


[Scoring]

If your output format is incorrect, you may get no points, and it may also cause unpredictable errors.

If your output format is correct, then if your kmink_{min} is correct, you will get 50%50\% of the score for the test point. If, on this basis, your construction is also correct, you will get 100%100\% of the score for the test point.


[Constraints]

For all data: 2n2×1052\leq n\leq 2\times 10^5, 1m2.3×1051\leq m\leq 2.3\times 10^5, 1x,yn1\leq x,y\leq n. It is guaranteed that among the given mm edges there are no multiple edges and no self-loops, and the given graph is connected.

Subtask ID mm\leq Special Constraints Score
Subtask 1\text{Subtask 1} 2×1052\times 10^5 GG is a path 1010
Subtask 2\text{Subtask 2} 1010 None
Subtask 3\text{Subtask 3} 20002000 GG is a tree 1515
Subtask 4\text{Subtask 4} None 2020
Subtask 5\text{Subtask 5} 10510^5 GG is a tree 1515
Subtask 6\text{Subtask 6} 2.3×1052.3\times 10^5 None 3030

Translated by ChatGPT 5