UVa 10048:audiophobia (Floyd, Kruskal)

Source: Internet
Author: User

Link:

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=989

Topic:

Problem B:audiophobia

Consider yourself lucky! Consider yourself lucky to be still breathing and has fun participating in this contest. But we apprehend that many of your descendants may not have this luxury. For, as your know, we are the dwellers of one of the most polluted cities on earth. Pollution is everywhere, both in the environment and in society and we lack of consciousness is simply aggravating the SI Tuation.

However, for the time being, we'll consider only one type of pollution-the sound pollution. The loudness or intensity level of sound are usually measured in decibels and sound has intensity level 130 decibels or Higher is considered painful. The intensity level of normal conversation are 6065 decibels and that's heavy traffic is 7080 decibels.

Consider the following city map where the edges refer to streets and the nodes to refer. The integer on the "Each edge is" average intensity level of sound (in decibels) into the corresponding street.

To get from crossing A to crossing G for you follow the following path:acfg. In the case you are capable of tolerating sound intensity as high as 140 decibels. For the paths Abeg, ABDG and ACFDG you must tolerate, respectively, decibels sound of intensity. There are other paths, too. However, it is clear this acfdg is the most comfortable path since it does don't demand you to tolerate more than Ibels.

In this problem, given a city map your are required to determine the minimum sound level you intensity is must to able Given crossing to another, rate in order

Input

The input may contain multiple test cases.

The ' a ' of each test case contains three integers

,

and

Where C indicates the number of crossings (crossings are numbered using distinct integers ranging from 1 to C), S Represen TS the number of streets and Q is the number of queries.

Each of the next S lines contains three integers:c1, C2 and D indicating this average sound level on the St Reet connecting the Crossings C1 and C2 (

) is D decibels.

Each of the next Q lines contains two integers c1 and C2 (

Asking for the "minimum sound intensity level you must is able to tolerate into order to get from crossing C1 to crossing C 2.

The input would terminate with three zeros form C, S and Q.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.