#P2169. 正则表达式
正则表达式
Description
In the Internet, computers are not directly connected one-to-one. Instead, some computers have one-way network connections. That is, even if there is a connection from to , there may not be a connection from to . Moreover, some connections are fast while others are slow, so the transmission time differs across connections. In addition, if both the connection from to and the connection from to exist, then and are effectively in the same LAN and can communicate locally, with a transmission time of .
Now Xiao Z gives you the topology of the network. He wants to know the shortest transmission time from his computer (numbered ) to Xiao X's computer (numbered ).
Input Format
The first line contains two integers , meaning there are computers and connections.
The next lines each contain three integers , meaning the time to transmit information from computer to computer is .
Output Format
Output a single line with the shortest transmission time.
3 2
1 2 1
2 3 1
2
5 5
1 2 1
2 3 6
3 4 1
4 2 1
3 5 2
3
Hint
- For of the data, , .
- For of the data, , .
- For of the data, , .
The answer is guaranteed to fit in the int range.
Translated by ChatGPT 5
京公网安备 11011102002149号