PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000014. Địa điểm hội họp (05-32 Rendezvous)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Địa điểm hội họp (05-32 Rendezvous)
05-32 Rendezvous
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Each of participants lives at a location. Choose whose home minimizes the sum of shortest undirected travel costs from everyone; on ties choose the earliest input name.
Input
, followed by names and weighted undirected edges.
Output
Print the selected participant name.
Subtasks
- Subtask 1 (40 points): ; ; ; ; .
- Subtask 2 (60 points): ; ; ; .
Examples
Input
3 2
Ana
Ben
Cam
1 2 1
2 3 1
Output
Ben
Explanation
Meeting at Ben gives total cost , compared with at either endpoint.