Bridges

A bridge of an undirected graph is defined as any edge whose removal
increases the number of connected components. Please compute all the
bridges of a given graph.

Input

Input consists of several cases, each with the number of vertices n,
followed by the number of edges m, followed by m pairs x y indicating an
edge between x and y, with x ≠ y. Assume 2 ≤ n ≤ 10⁴, 1 ≤ m ≤ 5n, that
vertices are numbered starting from zero, and that there is at most one
edge connecting any pair of vertices.

Output

For every graph, print the number of bridges, followed by a line with
those bridges. The two vertices of each bridge must be sorted
increasingly, and the bridges themselves must also be sorted
increasingly. Print a line with 10 dashes at the end of every case.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:33:23.177Z

© Jutge.org, 2006–2026.
https://jutge.org
