#P8435. Vertex Biconnected Components
Vertex Biconnected Components
Vertex Biconnected Components
Given an undirected graph with n vertices and m edges, you are required to find its vertex biconnected components (also known as 2-connected components). A biconnected component is a maximal set of vertices such that any two vertices in the set remain connected after the removal of any single vertex.
Your task is to compute all such biconnected components, output the total number of components, and then for each component output the number of vertices in the component followed by the sorted list of vertices in that component. Note that if a vertex is an articulation point, it may appear in more than one component.
Note: To ensure deterministic output, each component should have its vertices sorted in increasing order, and the list of components should be sorted in increasing order based on the first (smallest) vertex in each component. In case of a tie, sort by the next vertex, and so on.
inputFormat
The first line of input contains two integers n and m where 1 ≤ n, m ≤ 105 indicating the number of vertices and edges in the graph respectively.
Each of the following m lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) indicating an undirected edge between vertices u and v. There can be multiple edges or self-loops is not allowed.
outputFormat
Output the total number of vertex biconnected components in the first line. Then, for each component output a line beginning with the number of vertices in the component followed by a space-separated list of its vertices in increasing order.
The components themselves should be output in increasing order as determined by comparing the sorted vertex list of each component lexicographically.
sample
4 3
1 2
2 3
3 4
3
2 1 2
2 2 3
2 3 4
</p>