#P4822. [BJWC2012] 冻结

    ID: 3691 远端评测题 3000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2012北京图的建立,建图最短路

[BJWC2012] 冻结

Description

Let us consider the simplest travel problem: there are NN cities and MM bidirectional roads on this continent. The cities are numbered from 11 to NN. We start at city 11 and need to reach city NN. How can we arrive as fast as possible?

Is this not just the shortest path problem? We all know it can be solved using algorithms such as Dijkstra, Bellman-Ford, and Floyd-Warshall.

Now, we have KK SpellCards that can slow down time by 50%50\%. That is, when traveling along an edge, we may choose to use one card, so the time to pass that road becomes half of the original. Note that:

  1. On each road, at most one SpellCard can be used.
  2. Using one SpellCard only takes effect on one road.
  3. You do not have to use all SpellCards.

Given the above information, your task is to find the minimum time needed to travel from city 11 to city NN when you may use at most KK time-slowing SpellCards.

Input Format

The first line contains three integers: NN, MM, KK.

The next MM lines each contain three integers: AiA_i, BiB_i, TimeiTime_i, meaning there is a bidirectional road between AiA_i and BiB_i. Without using a SpellCard, passing through it takes TimeiTime_i time.

Output Format

Output one integer, the minimum time needed to travel from city 11 to city NN.

4 4 1 
1 2 4 
4 2 6 
1 3 8 
3 4 8 

7

Hint

Sample 1 Explanation

Without using any SpellCard, the shortest path is 1241 \to 2 \to 4, with total time 1010. Now we can use 11 SpellCard, so we halve the time on the road 242 \to 4, and the total time becomes 77.

Constraints

For 100%100\% of the testdata, it is guaranteed that:

  • 1KN501 \leq K \leq N \leq 50, M103M \leq 10^3.
  • 1Ai,BiN1 \leq A_i,B_i \leq N, 2Timei2×1032 \leq Time_i \leq 2 \times 10^3.
  • To ensure the answer is an integer, all TimeiTime_i are even.
  • The undirected graph in all data has no self-loops or multiple edges, and is connected.

Translated by ChatGPT 5