#P6431. [COCI 2008/2009 #1] KRTICA
[COCI 2008/2009 #1] KRTICA
Description
There is a tree with nodes, and all edge weights are .
Now you want to delete one edge and add one edge, so that the distance between the two farthest nodes is as small as possible.
Input Format
The first line contains an integer .
The next lines each contain two integers and , indicating that there is an undirected edge from to in the tree.
Output Format
This problem uses an SPJ.
The first line contains a single integer, which is the distance between the two farthest nodes after deleting one edge and adding one edge.
The second line contains two integers, indicating the edge that is deleted.
The third line contains two integers, indicating the edge that is added.
4
1 2
2 3
3 4
2
3 4
4 2
7
1 3
2 3
2 7
4 3
7 5
3 6
3
2 3
7 3
Hint
Constraints
- For of the testdata, is guaranteed.
- For of the testdata, is guaranteed.
- For of the testdata, , and .
Scoring
- If the first line of the output is incorrect, you get points.
- If the first line of the output is correct, but the remaining numbers are incorrect or fewer than four numbers are printed in total, you get of the score for the corresponding test point.
- If the first line of the output is correct, and the given solution is feasible and correct, you get of the score for the corresponding test point.
Notes
This problem is translated from T6 KRTICA of Croatian Open Competition in Informatics 2008/2009, Contest #1.
SPJ provided by @Tweetuzki.
Translated by ChatGPT 5
京公网安备 11011102002149号