#FW0000075. Vị trí trạm cứu hỏa mới (Fire Station)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Vị trí trạm cứu hỏa mới (Fire Station)
Fire Station
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given a connected undirected road network and existing fire stations, choose one new station location that minimizes the maximum distance from any intersection to its closest station. Break ties by the smallest intersection index. Reusing an existing station location is allowed.
Input
First , followed by existing station vertices and then undirected weighted roads, all 1-based.
Output
Print the selected intersection index.
Subtasks
-
Subtask 1 (40 points): . , , ; đồ thị liên thông.
-
Subtask 2 (60 points): . , , ; đồ thị liên thông.
Examples
Input
4 3 1
1
1 2 2
2 3 3
3 4 5
Output
3
Explanation
The existing station is at vertex 1. Candidates 3 and 4 both achieve maximum response distance 5, so the lower-numbered intersection 3 is chosen.