#Q76. 「一本通 3.2 例 3」架设电话线

    ID: 2159 Type: Default 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>最短路二分早于 2010USACO Contest一本通提高

「一本通 3.2 例 3」架设电话线

Description

Original source: USACO 2008 Jan. Silver

In the suburbs, there are NN communication base stations and PP bidirectional cables, where the ii-th cable connects base stations AiA_i and BiB_i. Notably, base station 11 is the main station of the communication company, and base station NN is located on a farm. Now, the farm owner wishes to upgrade the communication lines, where upgrading the ii-th cable costs LiL_i.

The telephone company is running a promotional offer. The farm owner can specify a path from base station 11 to base station NN and designate up to KK cables on this path to be upgraded for free by the telephone company. The farm owner only needs to pay for the cost of the most expensive remaining cable on the path after the free upgrades. Determine the minimum amount of money required to complete the upgrade.

In one sentence   \ \ On a weighted undirected graph, find a path from node 11 to node NN such that the (K+1)(K + 1)-th largest edge weight on the path is as small as possible.

Input Format

The first line contains three integers N,P,KN, P, K.

The next PP lines each contain three integers Ai,Bi,LiA_i, B_i, L_i.

Output Format

If there is no path from 11 to NN, output -1. Otherwise, output the minimum required cost.

Sample 1

5 7 1
1 2 5
3 1 4
2 4 8
3 2 3
5 2 9
3 4 7
4 5 6

4

Constraints & Hints

0K<N1000,1P20000 \le K < N \le 1000, 1 \le P\le 2000