QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#1000. 边三连通分量

统计

Source: Library Checker

Statement

Given a undirected graph with $N$ vertices and $M$ edges. $i$-th edge is $(a_i, b_i)$. This graph may not be simple. Please decompose this graph into three-edge-connected components.

$N$ 頂点 $M$ 辺の無向グラフが与えられる。$i$ 番目の辺は $(a_i, b_i)$ である。このグラフは単純とは限らない。 このグラフを三辺連結成分分解してください。

Constraint

  • $1 \leq N \leq 2\times 10^5$
  • $1 \leq M \leq 2 \times 10^5$
  • $0 \leq a_i, b_i < N$

Input

  • $N$ $M$
  • $a_0$ $b_0$
  • $a_1$ $b_1$
  • :
  • $a_{M - 1}$ $b_{M - 1}$

Output

Print the number of three-edge-connected components $K$ in the first line. Following $K$ lines, print as follows. $l$ is the number of vertices of three-edge-connected components and $v_i$ is a vertex index.

$K$ を三辺連結成分の個数として、$1 + K$ 行出力する。 最初の行には $K$ を出力し、その後 $K$ 行では以下のように出力する。$l$ は三辺連結成分の頂点数であり、$v_i$ はその頂点番号である。

  • $l$ $v_0$ $v_1$ ... $v_{l-1}$

If there is multiple solutions, print any of them.

正しい出力が複数存在する場合は、どれを出力しても構わない。

Example

Input 1

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

Output 1

3
2 0 2
1 1
1 3

Input 2

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

Output 2

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

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.