#P4517. [JSOI2018] 防御网络
[JSOI2018] 防御网络
Description
Although the attack plan of the aliens has been obtained, JYY unexpectedly finds that the alien mothership attacks Earth randomly. A defense network must be deployed on Earth as soon as possible to resist the mothership’s attack.
The defense network on Earth consists of nodes and energy links between nodes. The defense network can be regarded as a simple undirected graph with vertices and edges. Each defense node corresponds to a vertex in , and each energy link corresponds to an edge in . In addition, considering energy transmission efficiency when building the defense network, in each vertex belongs to at most one simple cycle.
Since the mothership’s attack is random, at the beginning of each attack, JYY will choose some defense nodes according to the current attack and use energy links to connect these defense nodes to activate a defense subnetwork. In other words, JYY will choose a subset of edges in , which satisfies:
- (Defense subnetwork connected) If we build a new graph , i.e., connect the vertices in with the edges in , then for any selected defense vertices , they are connected in .
- (Defense subnetwork minimal) Subject to condition 1 (defense subnetwork connected), the number of selected edges is minimal, i.e., is minimal.
is the Steiner tree generated by the set in graph , and is the minimal cost to activate the defense subnetwork. Considering the randomness of the mothership’s attack, JYY wants you to compute the expectation of the activation cost:
Input Format
The first line contains two integers , denoting the number of vertices and edges in the graph.
The next lines each contain two integers , representing an edge. The input guarantees no self-loops or multiple edges, and that each vertex belongs to at most one simple cycle.
Output Format
Output one line: the expected cost to activate the defense subnetwork.
Suppose the expectation is written in irreducible fraction form . Output the remainder of , where is the unique integer satisfying .
3 2
1 2
2 3
750000006
6 6
1 2
2 3
3 1
1 4
2 5
3 6
468750006
Hint
Sample explanation.
Sample 1 is a path and includes the following cases:
- .
- .
- .
Therefore , .
In sample input 2, , thus , $P \cdot Q^{-1} = 468,750,006 \text{ mod 1,000,000,007}$.
Constraints
- For 20% of the testdata, .
- For 40% of the testdata, .
- For 100% of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号