#P4542. [ZJOI2011] 营救皮卡丘
[ZJOI2011] 营救皮卡丘
Description
Pikachu has been taken away by Team Rocket using an evil scheme. Those three bad guys also left Ash with an open provocation. For Pikachu, and for justice, Ash and his friends set off without hesitation on the road to rescue Pikachu.
Team Rocket has a total of bases, and there are bidirectional roads between the bases. The bases are numbered from to . Ash’s team has people. They start from Pallet Town and plan to rescue Pikachu trapped in base . For convenience, we treat Pallet Town as base . At the beginning, all people are at node .
Due to Team Rocket’s heavy defenses, for any , to destroy base , one must first destroy bases to in order. Moreover, if base has not been destroyed, then because of chained defenses, once any member of Ash’s team enters base , they will be discovered and serious consequences will occur. Therefore, before base is destroyed, no one can pass through base .
To simplify the problem, we ignore fighting. If any member of Ash’s team passes through base , then base is considered destroyed. A destroyed base can still be passed through.
The people may act separately. As long as after base is destroyed, any one person passes through base , then base is destroyed. Obviously, once base is destroyed, Pikachu is rescued.
The roads in the wild are unsafe, so while destroying base to rescue Pikachu, Ash’s team wants the total length of roads traveled by all people to be as small as possible.
Please help Ash design the best rescue plan.
Input Format
The first line contains three positive integers . This means there are nodes numbered from to , and undirected edges. At the beginning, Ash’s team has people, all located at node .
The next lines each contain three non-negative integers. On the -th line, the integers are , , , meaning there is a road of length between base and base .
Output Format
Output only one integer , the minimum total road length required to rescue Pikachu.
3 4 2
0 1 1
1 2 1
2 3 100
0 3 1
3
Hint
[Sample Explanation]
Ash and Misty go to rescue Pikachu together. In the optimal plan, Ash first goes from Pallet Town to node , then goes to base . After Ash successfully destroys base , Misty sets off from Pallet Town and goes directly to base , rescuing Pikachu.
For of the testdata, it holds that $N\le 150, M \le 20 000, 1 \le K \le 10, L_i \le 10 000$. It is guaranteed that Ash’s team can rescue Pikachu.
As for why , you may assume that in the end, under Ash’s call, Ash, Misty, Brock, Tracey, May, Max, Dawn, Iris, Cilan, and also Officer Black Cat who is traveling in Japan, all go together to fight Team Rocket.
Translated by ChatGPT 5
京公网安备 11011102002149号