PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000006. Thành phố ít láng giềng nhất (Find the City With the Smallest Number of Neighbors at a Threshold Distance)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Thành phố ít láng giềng nhất (Find the City With the Smallest Number of Neighbors at a Threshold Distance)

Find the City With the Smallest Number of Neighbors at a Threshold Distance

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Among cities 00 through n−1n-1, count the other cities with shortest path distance at most TT. Return a city with minimum count, breaking ties by larger index.

Input

n,m,Tn,m,T followed by mm undirected weighted edges.

Output

Print the selected city index.

Subtasks

  • Subtask 1 (40 points): n≤8n\le 8; 2≤n≤1002\le n\le 100; 1≤T≤100001\le T\le 10000; 0≤m≤n∗(n−1)/20\le m\le n*(n-1)/2; 0≤u,v<n0\le u,v<n; 1≤w≤100001\le w\le 10000.
  • Subtask 2 (60 points): 2≤n≤1002\le n\le 100; 1≤T≤100001\le T\le 10000; 0≤m≤n∗(n−1)/20\le m\le n*(n-1)/2; 0≤u,v<n0\le u,v<n; 1≤w≤100001\le w\le 10000.

Examples

Input

4 3 2
0 1 2
1 2 2
2 3 2

Output

3

Explanation

At threshold 22, the neighbor counts for cities 0,1,2,30,1,2,3 are 1,2,2,11,2,2,1. The tie is broken toward the larger index, 33.