#graph1005. 营救皮卡丘
营救皮卡丘
Rescue Pikachu
Problem Source
ZJOI 2011
Problem Description
Pikachu has been kidnapped by Team Rocket using an evil trick, and they even left a naked provocation for Ash! For Pikachu's sake, and for justice, Ash and his friends set out on a journey to rescue Pikachu without hesitation.
Team Rocket has strongholds, with bidirectional roads between them. The strongholds are numbered from to . Ash and his group of companions set out from Pallet Town to rescue Pikachu, who is trapped in stronghold . For convenience, we treat Pallet Town as stronghold , and initially all companions are at stronghold .
Because of Team Rocket's heavy defences, to destroy stronghold you must first destroy strongholds through in order; moreover, if stronghold has not been destroyed, due to the chain of defence, anyone from Ash's group who enters stronghold will be discovered, with serious consequences. Therefore, no one is allowed to pass through stronghold before stronghold is destroyed.
To simplify the problem, we ignore the fighting phase: anyone from Ash's group passing through stronghold is considered to have destroyed stronghold . A destroyed stronghold can still be passed through.
The companions may split up and act separately; as long as any one of them passes through stronghold after stronghold is destroyed, stronghold is destroyed. Obviously, once stronghold is destroyed, Pikachu is saved.
The roads in the wild are unsafe, so Ash's group hopes that, while rescuing Pikachu by destroying stronghold , the total length of roads travelled by the companions is minimized.
Please help Ash design the best rescue plan!
Input Format
The first line contains three positive integers $N\ (1 \le N \le 150), M\ (1 \le M \le 2 \times 10^4), K\ (1 \le K \le 10)$. There are strongholds in total, numbered from to , and undirected edges. Initially all companions of Ash's group are at stronghold .
The next lines each contain three non-negative integers; the -th line has , meaning there is a road of length from stronghold to stronghold . It is guaranteed that Ash's group can certainly rescue Pikachu.
Output Format
Contains only one integer : the minimum total length of roads that must be travelled to rescue Pikachu.
Sample Input
3 4 2
0 1 1
1 2 1
2 3 100
0 3 1
Sample Output
3
Hint
Ash and Misty go together to rescue Pikachu. In the optimal plan, Ash first goes from Pallet Town to stronghold 1, then to stronghold 2. After Ash destroys stronghold 2, Misty sets out from Pallet Town straight to stronghold 3 and rescues Pikachu.
As for why , you may think of it as: inspired by Ash, Ash, Misty, Brock, Tracey, May, Max, Dawn, Iris, Cilan, and the Police Inspector Black Cat who is travelling in Japan, all go together to battle Team Rocket.