[BOJ 6247] Widening of Channels

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 128M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

In the Waterland country, there are n lakes (numbered from 1 to n) and m channels between them. The width (in meters) of each channel is known. Navigation in the channels can be performed in both directions. It is known that a boat with width of one meter can reach any lake, starting from lake number 1.</p>

Write program channels, which calculates the minimum number of channels that should be widened, so that a boat with width of k meters can make a trip between every two lakes (the boat can move from one lake to another, if its width is less than or equal to the width of the channel, connecting the lakes).

입력 형식

On the first line of the standard input are given integers, n and m (1 < n ≤ 1000, 1 < m ≤ 100000).</p>

On each of the next m lines are given three integers, i, j and w, showing that there is a channel of width w (1 ≤ w ≤ 200) between lakes, i and j (1 ≤ i, j ≤ n).

On the last line is given the integer k (1 ≤ k ≤ 200).

출력 형식

On a line of the standard output the program have to write one integer: the minimum number of channels that should be widened.

예제 입력

6 9
1 6 1
1 2 2
1 4 3
2 3 3
2 5 2
3 4 4
3 6 2
4 5 5
5 6 4
4

예제 출력

2

Comments

There are no comments at the moment.