CF687D.Dividing Kingdom II
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves.
The great kingdom consisted of n cities numbered from 1 to n and m bidirectional roads between these cities, numbered from 1 to m . The i -th road had length equal to wi . The Great Arya and Pari The Great were discussing about destructing some prefix (all road with numbers less than some x ) and suffix (all roads with numbers greater than some x ) of the roads so there will remain only the roads with numbers l,l+1,...,r−1 and r .
After that they will divide the great kingdom into two pieces (with each city belonging to exactly one piece) such that the hardness of the division is minimized. The hardness of a division is the maximum length of a road such that its both endpoints are in the same piece of the kingdom. In case there is no such road, the hardness of the division is considered to be equal to −1 .
Historians found the map of the great kingdom, and they have q guesses about the l and r chosen by those great rulers. Given these data, for each guess li and ri print the minimum possible hardness of the division of the kingdom.
输入格式
The first line of the input contains three integers n , m and q ( 1<=n,q<=1000 , ) — the number of cities and roads in the great kingdom, and the number of guesses, respectively.
The i -th line of the following m lines contains three integers ui , vi and wi ( 1<=ui,vi<=n,0<=wi<=109 ), denoting the road number i connects cities ui and vi and its length is equal wi . It's guaranteed that no road connects the city to itself and no pair of cities is connected by more than one road.
Each of the next q lines contains a pair of integers li and ri ( 1<=li<=ri<=m ) — a guess from the historians about the remaining roads in the kingdom.
输出格式
For each guess print the minimum possible hardness of the division in described scenario.
输入输出样例
输入#1
5 6 5 5 4 86 5 1 0 1 3 38 2 1 33 2 4 28 2 3 40 3 5 2 6 1 3 2 3 1 6
输出#1
-1 33 -1 -1 33