P8435 [Template] Vertex-Biconnected Components

Description

Given an undirected graph with $n$ nodes and $m$ edges, output the number of its vertex-biconnected components, and output each vertex-biconnected component.

Input Format

The first line contains two integers $n$ and $m$. The next $m$ lines each contain two integers $u, v$, representing an undirected edge.

Output Format

The first line contains an integer $x$, the number of vertex-biconnected components. The next $x$ lines: the first number is $a$, the number of nodes in this component, followed by $a$ numbers describing a vertex-biconnected component. You may output the vertex-biconnected components in any order, and the nodes within each component in any order.

Explanation/Hint

**Explanation for Sample 4:** ![](https://cdn.luogu.com.cn/upload/image_hosting/huvwgbuo.png) Nodes with the same color belong to the same component. **Friendly reminder: Please carefully consider isolated nodes and self-loops (Sample 5).** ------------ **Constraints:** For $100\%$ of the testdata, $1 \le n \le 5 \times 10^5$, $1 \le m \le 2 \times 10^6$. | subtask | $n$ | $m$ | Score | | :----------: | :----------: | :----------: | :----------: | | $1$ | $1 \le n \le 100$ | $1 \le m \le 500$ | $25$ | | $2$ | $1 \le n \le 5000$ | $1 \le m \le 5 \times 10^4$ | $25$ | | $3$ | $1 \le n \le 2\times 10^5$ | $1 \le m \le 5\times 10^5$ | $25$ | | $4$ | $1 \le n \le 5 \times10 ^5$ | $1 \le m \le 2 \times 10^6$ | $25$ | This problem is not strict on constant factors. Both the time limit and memory limit are set large, so any correct solution can pass. ------------ ### Data Updates - $2022/7/14$ Strengthened the testdata. - $2022/11/26$ Added $10$ groups of smaller testdata ($1 \le n, m \le 10$) for easier debugging. - $2022/12/31$ Reorganized the $subtask$ setup and added several groups of extreme testdata. - $2023/1/1$ Found an issue in the testdata added yesterday, and it has been fixed. - $2025/10/29$ [Added an extra hack test](/ticket/VCUU554769). ------------ Surprise: After getting AC, remember to place your mouse over the test points to see the feedback information. There is a surprise. Translated by ChatGPT 5