#P6628. [省选联考 2020 B 卷] 丁香之路
[省选联考 2020 B 卷] 丁香之路
Problem Description
As spring arrives and everything comes back to life, with the pandemic gradually ending, Yazid takes his good friends to visit the campus of University T. For convenience, we number them from to .
The map of University T’s campus can be abstracted as an undirected graph with vertices (numbered from to ). For any two different vertices with indices , there is an undirected edge between them, and it takes units of time to traverse.
Lilac is one of the symbolic flowers of University T. At present, lilacs are in bloom, and among the roads on campus, lilacs bloom on all of them. Yazid’s friends are very interested in lilacs, so they all want to traverse all of the roads where lilacs bloom.
Yazid’s friends start from vertex . The -th friend wants to end the visit at vertex . Meanwhile, as described above, each friend must traverse each of the roads with lilacs at least once.
Yazid’s friends do not want to get too tired, so they hope to spend as little time as possible to achieve their goals.
Please compute how many units of time each of Yazid’s friends needs to spend to complete their goal.
Input Format
The first line contains non-negative integers . It is guaranteed that ; and .
Lines to each contain integers , describing an undirected edge with lilacs that connects vertices . It is guaranteed that and ; and each undirected edge is described at most once.
In every input line, multiple integers are separated by a single space.
Output Format
Output one line containing integers separated by a single space. The -th integer indicates the minimum time Yazid’s -th friend needs to complete the goal.
4 3 1
1 2
4 2
3 1
6 7 8 7
6 0 2
1 0 1 2 3 4
5 4 1
1 2
3 4
4 5
3 5
8 7 6 7 8
Hint
Sample Explanation 1
One optimal route for the -st friend is to start from , then go through in order, and finally return to , costing units of time.
One optimal route for the -nd friend is to start from , then go through in order, and finally arrive at , costing units of time.
One optimal route for the -rd friend is to start from , then go through in order, and finally arrive at , costing units of time.
One optimal route for the -th friend is to start from , then go through in order, and finally arrive at , costing units of time.
Sample Explanation 2
Since , there are no mandatory roads, so each friend can go directly to the destination via a single edge.
Constraints and Notes
| Test Point ID | Other Special Constraints | |
|---|---|---|
Translated by ChatGPT 5