Boomerangs
Time limit2sMemory limit512 MB
Count pairs of adjacent edges in a connected graph whose removal disconnects the graph.
- Level
Medium7 of 10
- Topics
- Graph, DFS, Implementation, Brute force
- Solved
- No attempts yet
Problem
You are given a graph . consists of vertices and edges and is connected. There are no self-loops, and no two edges share the same pair of endpoints.
If there exist vertices such that there is an edge between and and an edge between and , this pair of edges is called a boomerang.
Find the number of boomerangs such that removing the two edges of the boomerang leaves at least one pair of vertices that cannot reach each other along any sequence of edges.
Input
The first line gives and . ()
The next lines give edge information as and , meaning there is an edge between vertex and vertex . (, )
Output
Print the number of boomerangs whose removal increases the number of connected components.