#P2136. 拉近距离
拉近距离
Description
In the lives of Xiao Ming and Xiao Hong, there are key nodes. There are events, denoted as a triplet , meaning that from node there is an event that can move to , and the effect of the event is to reduce the distance between them by .
These nodes form a network, in which nodes and are special: node represents Xiao Ming, node represents Xiao Hong, and the others represent stages of progress. You may freely choose whether to perform each event, but at any step you may only perform an event that is outgoing from the current node. Please write a program to compute the shortest possible distance between them.
Input Format
The first line contains two positive integers .
Then follow lines, each containing space-separated integers .
Output Format
Output one line with a single integer representing the shortest possible distance between them. If this distance can be decreased without bound, output Forever love.
3 3
1 2 3
2 3 -1
3 1 -10
-2
Hint
For of the testdata, , .
For of the testdata, , .
For of the testdata, , , . It is guaranteed that there is a path from node to every node , and from node to every node .
Translated by ChatGPT 5
京公网安备 11011102002149号