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
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
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 through , count the other cities with shortest path distance at most . Return a city with minimum count, breaking ties by larger index.
Input
followed by undirected weighted edges.
Output
Print the selected city index.
Subtasks
- Subtask 1 (40 points): ; ; ; ; ; .
- Subtask 2 (60 points): ; ; ; ; .
Examples
Input
4 3 2
0 1 2
1 2 2
2 3 2
Output
3
Explanation
At threshold , the neighbor counts for cities are . The tie is broken toward the larger index, .