#P2680. [NOIP 2015 提高组] 运输计划
[NOIP 2015 提高组] 运输计划
Description
In the year , humanity entered the cosmic era.
Country L has planets and bidirectional routes. Each route is built between two planets, and these routes connect all the planets in Country L.
Xiao P runs a logistics company that has many transportation plans. Each plan is as follows: a cargo spaceship needs to travel from planet to planet along the fastest space route. Obviously, traversing a route takes time. For route , any spaceship takes time to traverse it, and any two spaceships do not interfere with each other.
To encourage technological innovation, the king of Country L allows Xiao P’s logistics company to participate in route construction, that is, to transform one route into a wormhole. Traversing the wormhole takes no time.
Before the wormhole is completed, Xiao P’s company has already pre-booked transportation plans. After the wormhole is completed, these plans will start simultaneously, and all spaceships depart together. When all plans are completed, Xiao P’s company finishes this phase of work.
If Xiao P can freely choose which route to convert into a wormhole, find the minimum time required for the company to complete this phase of work.
Input Format
The first line contains two positive integers , representing the number of planets in Country L and the number of transportation plans pre-booked by Xiao P’s company. Planets are numbered from to .
The next lines describe the construction of the routes. The -th line contains three integers , and , indicating that the -th bidirectional route is built between planets and , and any spaceship takes time to traverse it.
The next lines describe the transportation plans. The -th line contains two positive integers and , indicating that the -th plan is to travel from planet to planet .
Output Format
Output one integer, the minimum time required for Xiao P’s logistics company to complete this phase of work.
6 3
1 2 3
1 6 4
3 1 7
4 3 6
3 5 5
3 6
2 5
4 5
11
Hint
The Constraints and characteristics of all testdata are shown in the table below.
| Test point ID | Convention | ||
|---|---|---|---|
| 1 | |||
| 2 | ^ | The -th route connects planet and planet . | |
| 3 | ^ | ||
| 4 | ^ | ||
| 5 | The -th route connects planet and planet . | ||
| 6 | ^ | ||
| 7 | |||
| 8 | |||
| 9 | ^ | ||
| 10 | |||
| 11 | |||
| 12 | ^ | ||
| 13 | The -th route connects planet and planet . | ||
| 14 | ^ | ||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | ^ | ||
| 19 | |||
| 20 | |||
| All testdata | , | ||
Please pay attention to the impact of constant factors on program efficiency.
Translated by ChatGPT 5
京公网安备 11011102002149号