#P4542. [ZJOI2011] 营救皮卡丘

    ID: 3481 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2011各省省选浙江图的建立,建图最短路费用流

[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 NN bases, and there are MM bidirectional roads between the bases. The bases are numbered from 11 to NN. Ash’s team has KK people. They start from Pallet Town and plan to rescue Pikachu trapped in base NN. For convenience, we treat Pallet Town as base 00. At the beginning, all KK people are at node 00.

Due to Team Rocket’s heavy defenses, for any 2XN2\le X\le N, to destroy base XX, one must first destroy bases 11 to X1X-1 in order. Moreover, if base X1X-1 has not been destroyed, then because of chained defenses, once any member of Ash’s team enters base XX, they will be discovered and serious consequences will occur. Therefore, before base X1X-1 is destroyed, no one can pass through base XX.

To simplify the problem, we ignore fighting. If any member of Ash’s team passes through base KK, then base KK is considered destroyed. A destroyed base can still be passed through.

The KK people may act separately. As long as after base K1K-1 is destroyed, any one person passes through base KK, then base KK is destroyed. Obviously, once base NN is destroyed, Pikachu is rescued.

The roads in the wild are unsafe, so while destroying base NN to rescue Pikachu, Ash’s team wants the total length of roads traveled by all KK people to be as small as possible.

Please help Ash design the best rescue plan.

Input Format

The first line contains three positive integers N,M,KN,M,K. This means there are N+1N+1 nodes numbered from 00 to NN, and MM undirected edges. At the beginning, Ash’s team has KK people, all located at node 00.

The next MM lines each contain three non-negative integers. On the ii-th line, the integers are AiA_i, BiB_i, LiL_i, meaning there is a road of length LiL_i between base AiA_i and base BiB_i.

Output Format

Output only one integer SS, 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 11, then goes to base 22. After Ash successfully destroys base 22, Misty sets off from Pallet Town and goes directly to base 33, rescuing Pikachu.

For 100%100\% 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 K10K \le 10, 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