Problems > Critical Wires

Critical Wires

Difficulty: 1900 4000 ms 128 MB

graphs

A bridge is an edge whose removal disconnects its endpoints. Count the bridges of the undirected graph (multi-edges between the same pair are never bridges).

Input: the first line has N and M; each of the next M lines has an edge u v.

Output: the number of bridges.

Constraints:

  • 1 ≤ N ≤ 104
  • 0 ≤ M ≤ 2×104

Sample Tests

Input 1
5 5
1 2
2 3
3 1
3 4
4 5
Output 1
2
Input 2
2 2
1 2
1 2
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.