NKOJ [NOIP2015 Day2] transport plan

Time limit: 20000 MS    Space limitations: 262144 KB
Benchmark Description: 2s, 256m
Problem Description

The year 2044, humanity has entered the cosmic era. 
L n-owned planet, there are n-1 bidirectional channel, each channel is established between the two planets, which the n-1 communication channel all the planets L States. 
Little P, in charge of a logistics company, the company has a number of transportation planning, transportation plans for each of the form: there is a need for logistics spacecraft flight from ui number planet along the fastest path to vi number of aerospace planet go. Obviously, the spacecraft passing a course it takes time for the channel j, any ship passing of time it takes for tj, and will not produce any interference between any two spacecraft. 
In order to encourage scientific and technological innovation, the king agreed to a small country L P logistics companies involved in waterway construction L States that allows the transformation of a small P channel into a wormhole, wormhole passing spacecraft is not time consuming. 
Before the completion of the construction of small P wormhole logistics companies pre-wired by m transport plan. After the completion of the construction of the wormhole, the m transportation plan will also begin, starting with all the spacecraft. When the m transportation plans are complete, a small logistics company P stage work is complete. 
If the small P is free to choose which of course will be transformed into a wormhole and try to find small P logistics company completed the minimum time needed for the work stage is how much?

Input Format

        / * Input file named transport.in. * /
        The first line includes two positive integers n, m, L represents the number of stars in the countries and the small number of pre-contact P's transportation schedule, from planet numbered 1 to n.
        Next, construction of the line n-1 channel is described, wherein the i-th row comprising three integers ai, bi and ti, showing the construction of the i-th two-way route between two planets ai and bi, it would take any of the spacecraft passing the time ti.
        Next m lines describe the case of transportation planning, where the first line contains two positive integers j ui and vi, j th transport plan from planet to vj uj No. No. planet.

Output Format

        / * Output file name transport.out. * /
        Total 1 line, includes an integer representing the small P logistics company completed the minimum time required for stage work.

Sample input

1 Sample input:
. 6. 3
1 2. 3
1. 6. 4
. 3. 7 1
. 4. 3. 6
. 3. 5. 5
. 3. 6
2. 5
. 4. 5

Sample Output

Sample Output 1:
. 11

prompt

Description Input Output Sample 1:
        the transformation into a wormhole Article 1 channel, the program takes three were 11,12,11, and therefore the time it takes to 12;
        the transformation into a wormhole article waterway 2, then the three 7,15,11 were planned time-consuming, so the time it takes is 15;
        the transformation of article 3 of the fairway into a wormhole, the program takes three to 8, 11, respectively, so the time it takes is 11;
        Article 4 of the fairway transformed into a wormhole, the three plans were 11,15,5 time-consuming, so the time it takes is 15;
        the transformation of Article 5 of the fairway into a wormhole, the program takes three to 11, respectively, 10,6, so the time it takes for 11.
        Therefore, the Article 3 or Article 5 of the fairway can make the stage transformed into a wormhole of time-consuming work shortest time it takes for 11.

Data on the size of the agreement:

 

Guess you like

Origin www.cnblogs.com/Limbo-To-Heaven/p/11372636.html