TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Given a undirected graph with $N$ vertices and $M$ edges. $i$-th edge is $(a _ i, b _ i)$. This graph may not be simple but never has a self-loop.
Decompose this graph into biconnected components and output their vertex sets.

A biconnected component is a maximal biconnected subgraph.

Input Format

$N$ $M$
$a _ 0$ $b _ 0$
$a _ 1$ $b _ 1$
:
$a _ {M-1}$ $b _ {M-1}$

Output Format

Print the number of biconnected components $K$ in the first line.
Following $K$ lines, print as follows. $l$ is the number of vertices of biconnected components and $v _ i$ is an vertex index.
$l$ $v _ 0$ $v _ 1$ ... $v _ {l-1}$

If there is multiple solutions, print any of them.

Sample Input 1

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

Sample Output 1

1
4 0 1 2 3

Sample Input 2

10 12
0 6
0 8
1 2
1 6
2 6
3 6
3 9
4 9
4 7
5 6
5 9
6 8

Sample Output 2

5
3 0 6 8
3 1 2 6
4 3 5 6 9
2 4 7
2 4 9

Sample Input 3

5 3
0 1
1 0
0 1

Sample Output 3

4
2 0 1
1 2
1 3
1 4

Hints

  • $1 \leq N \leq 5 \times 10^ {5}$
  • $0 \leq M \leq 5 \times 10^ {5}$
  • $0 \leq a _ i, b _ i \lt N$
  • $a _ i \neq b _ i$

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 2097152 2097152
1 5000 2097152 2097152
2 5000 2097152 2097152
3 5000 2097152 2097152
4 5000 2097152 2097152
5 5000 2097152 2097152
6 5000 2097152 2097152
7 5000 2097152 2097152
8 5000 2097152 2097152
9 5000 2097152 2097152
10 5000 2097152 2097152
11 5000 2097152 2097152
12 5000 2097152 2097152
13 5000 2097152 2097152
14 5000 2097152 2097152
15 5000 2097152 2097152
16 5000 2097152 2097152
17 5000 2097152 2097152
18 5000 2097152 2097152
19 5000 2097152 2097152
20 5000 2097152 2097152
21 5000 2097152 2097152