#d1904. 【模板】最小瓶颈生成树(数据加强版)
【模板】最小瓶颈生成树(数据加强版)
[Template] Minimum Bottleneck Spanning Tree (Hard Version)
Problem Description
You are given an undirected graph with vertices and edges, each edge having a weight. Define the bottleneck of a path from vertex to vertex as the maximum weight on that path. There are queries; each query gives two vertices . For each query, find the minimum bottleneck over all paths from to .
It is guaranteed that the graph is connected.
Input Format
The first line contains two positive integers () and (), the numbers of vertices and edges.
Lines to each contain three integers (), denoting an undirected edge of weight between and .
Line contains a positive integer (), the number of queries. The following lines each contain two positive integers (), the start and end vertices.
Output Format
For each query, output one integer on its own line: the minimum bottleneck.
Note: Because the input and output sizes of this problem are very large, please use fast I/O.
Sample Input
2 1
1 2 10
1
1 2
Sample Output
10