#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 NN strongholds, with MM bidirectional roads between them. The strongholds are numbered from 11 to NN. Ash and his group of KK companions set out from Pallet Town to rescue Pikachu, who is trapped in stronghold NN. For convenience, we treat Pallet Town as stronghold 00, and initially all KK companions are at stronghold 00.

Because of Team Rocket's heavy defences, to destroy stronghold xx you must first destroy strongholds 11 through x−1x-1 in order; moreover, if stronghold x−1x-1 has not been destroyed, due to the chain of defence, anyone from Ash's group who enters stronghold xx will be discovered, with serious consequences. Therefore, no one is allowed to pass through stronghold xx before stronghold x−1x-1 is destroyed.

To simplify the problem, we ignore the fighting phase: anyone from Ash's group passing through stronghold xx is considered to have destroyed stronghold xx. A destroyed stronghold can still be passed through.

The KK companions may split up and act separately; as long as any one of them passes through stronghold xx after stronghold x−1x-1 is destroyed, stronghold xx is destroyed. Obviously, once stronghold NN is destroyed, Pikachu is saved.

The roads in the wild are unsafe, so Ash's group hopes that, while rescuing Pikachu by destroying stronghold NN, the total length of roads travelled by the KK 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 N+1N+1 strongholds in total, numbered from 00 to NN, and MM undirected edges. Initially all KK companions of Ash's group are at stronghold 00.

The next MM lines each contain three non-negative integers; the ii-th line has Ai,Bi,Li (0≤Li≤104)A_i, B_i, L_i\ (0 \le L_i \le 10^4), meaning there is a road of length LiL_i from stronghold AiA_i to stronghold BiB_i. It is guaranteed that Ash's group can certainly rescue Pikachu.

Output Format

Contains only one integer SS: 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 K≤10K \le 10, 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.