PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000049. Vận chuyển hàng nặng (Heavy Cargo)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Vận chuyển hàng nặng (Heavy Cargo)
Heavy Cargo
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Undirected roads link named cities and have maximum load capacities. Find a route from the starting city to the destination whose minimum edge capacity is as large as possible.
Input
First n m; then n distinct city names, then m lines cityA cityB capacity, then sourceCity targetCity.
Output
Print the maximum cargo load, or 0 if no route exists.
Subtasks
- Subtask 1 (40 points): . The n city names are distinct. Roads are undirected and have different endpoints; parallel roads are allowed.
- Subtask 2 (60 points): . The n city names are distinct. Roads are undirected and have different endpoints; parallel roads are allowed.
Examples
Input
3 3
A B C
A B 8
B C 5
A C 3
A C
Output
5
Explanation
A–C directly supports load 3; the route A–B–C supports min(8,5)=5, which is optimal.