Cactus graph edge removal
Time limit1sMemory limit512 MB
Delete uniformly random edges one at a time from a cactus graph until it disconnects, and output the expected number of deletions to six decimals.
- Level
Medium7 of 10
- Topics
- Probability, Graph, DFS, Math
- Solved
- No attempts yet
Problem
A cactus graph is a connected undirected graph in which every two distinct simple cycles share at most one vertex. A simple cycle is a cycle that does not repeat a vertex. In a cactus graph, no two such cycles overlap in two or more vertices.
You play a game on a given cactus graph. In each step you pick one of the remaining edges and delete it. The edge is picked uniformly at random among all remaining edges, and the choices in different steps are independent. The game ends once the graph is no longer connected, that is, once there are two vertices with no path between them.
Compute the expected number of steps until the game ends.
Input
The first line contains the number of vertices and the number of edges . (, ) The vertices of the graph are numbered from to .
Each of the next lines contains two different integers and . () They mean that an edge joins vertex and vertex .
At most one edge joins any two vertices, and the given graph is a cactus graph as described above.
Output
Print the expected number of steps until the game ends on one line. Round it to six places after the decimal point and print exactly six digits after the decimal point.