PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000048. Nỗi sợ tiếng ồn (Audiophobia)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nỗi sợ tiếng ồn (Audiophobia)
Audiophobia
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
In an undirected road network each edge has a noise level. For every queried pair of cities, find a route minimizing the greatest noise level of an edge used on that route.
Input
First n m q; then m lines u v w (1-based), then q lines s t.
Output
For each query print the minimum possible maximum noise level, or -1 if disconnected; print 0 if s=t.
Subtasks
- Subtask 1 (40 points): $2\le n\le 8,\ 0\le m\le 20,\ 1\le q\le 15,\ 1\le w\le 100$. The graph is undirected; 1 <= u,v,s,t <= n and u != v for every edge. Parallel edges and disconnected components are allowed.
- Subtask 2 (60 points): $2\le n\le 100,\ 0\le m\le 500,\ 1\le q\le 100,\ 1\le w\le 10^5$. The graph is undirected; 1 <= u,v,s,t <= n and u != v for every edge. Parallel edges and disconnected components are allowed.
Examples
Input
4 4 3
1 2 7
2 3 3
1 3 10
3 4 5
1 3
1 4
2 2
Output
7
7
0
Explanation
The route 1–2–3 has maximum noise 7, beating the direct edge with noise 10. Extending it to 4 adds an edge of noise 5, so the maximum stays 7. A zero-length trip from 2 to itself costs 0.