#P4366. [Code+#4] 最短路
[Code+#4] 最短路
Description
There are cities in the Penguin Kingdom, numbered from to .
For any two cities and , penguins can spend time to travel from city to city , where is a given constant.
In addition, there are one-way express channels. The -th express channel goes from city to city , and taking this channel costs time.
Now a penguin named Doudou from Penguin Kingdom University is considering the minimum time needed to travel from city to city .
Input Format
Read from standard input.
The first line of input contains three integers , representing the number of cities, the number of express channels, and the given constant mentioned in the statement.
The next lines each contain three positive integers (, ), representing the start city, the end city, and the time cost of taking this channel, respectively.
The last line contains two positive integers , representing the start city and the end city chosen by Doudou.
Output Format
Output to standard output.
Output one line with a single integer, the minimum time required to travel from city to city .
4 2 1
1 3 1
2 4 4
1 4
5
7 2 10
1 3 1
2 4 4
3 6
34
Hint
Sample 1 explanation.
It is optimal to go directly from to .
Sample 2 explanation.
First go from to , then take the channel from to , and finally go from to .

The lively and lovely problem setter left everyone the picture below.

Credit: https://www.luogu.org/discuss/show/38908
Translated by ChatGPT 5
京公网安备 11011102002149号