#P4568. [JLOI2011] 飞行路线

[JLOI2011] 飞行路线

Description

Alice and Bob are going to travel by plane, and they chose a relatively cheap airline. This airline operates in nn cities, labeled 00 to n1n-1, and there are mm routes. Each route connects two cities and has a certain price.

Alice and Bob need to travel from one city to another along these routes, and they may transfer. The airline offers a discount for this trip: they can take flights on at most kk routes for free. What is the minimum total cost for their trip?

Input Format

The first line contains three integers n,m,kn, m, k, representing the number of cities, the number of routes, and the maximum number of free rides, respectively.

The next line contains two integers s,ts, t, representing the starting city and the destination city.

The next mm lines each contain three integers a,b,ca, b, c, indicating that there is a bidirectional route between cities aa and bb with price cc.

Output Format

Output a single integer on one line, which is the minimum total cost.

5 6 1
0 4
0 1 5
1 2 5
2 3 5
3 4 5
2 3 3
0 2 100
8

Hint

Constraints

For 30%30\% of the testdata, 2n502 \le n \le 50, 1m3001 \le m \le 300, k=0k=0.

For 50%50\% of the testdata, 2n6002 \le n \le 600, 1m6×1031 \le m \le 6\times10^3, 0k10 \le k \le 1.

For 100%100\% of the testdata, 2n1042 \le n \le 10^4, 1m5×1041 \le m \le 5\times 10^4, 0k100 \le k \le 10, 0s,t,a,b<n0 \le s,t,a,b < n, aba \ne b, 0c1030 \le c \le 10^3.

There is also a set of hack testdata.

Translated by ChatGPT 5