#P3232. [HNOI2013 / JSOI2013] 游走
[HNOI2013 / JSOI2013] 游走
Description
Given an undirected connected graph with vertices and edges. The vertices are numbered from to , and the edges are to be numbered from to .
Xiao Z performs a random walk on this graph. Initially, Xiao Z is at vertex . At each step, Xiao Z chooses one incident edge of the current vertex uniformly at random, traverses it to the next vertex, and obtains a score equal to the label of that edge. The walk ends when Xiao Z reaches vertex . The total score is the sum of all scores obtained. Now, please assign labels to the edges so that the expected value of Xiao Z’s total score is minimized.
Input Format
The first line contains two integers, representing the number of vertices and the number of edges .
The next lines each contain two integers , indicating that there is an edge between vertices and .
Output Format
Output one real number: the answer, rounded to three decimal places.
3 3
2 3
1 2
1 3
3.333
Hint
Explanation for Sample 1
Edge is labeled , edge is labeled , and edge is labeled .
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , ; the given graph has no multiple edges and no self-loops, and every node is reachable from .
Translated by ChatGPT 5
京公网安备 11011102002149号