A little thought about difference constraints

When reviewing difference constraints, I suddenly forgot why finding the largest solution runs the shortest path, and finding the smallest solution runs the longest path. . . So write it down, in case you forget it later. . .
Boss He's proof is like this:
Prove the shortest path (NKOJ3459):
write picture description here
Or this:
write picture description here
Both pictures can be found in the boss's sex T

Then. . I don't understand. . .
I think slowly, and it seems that I have found a more understandable method (it should be right...)
Let's talk about the shortest way first.
Obviously, for dis[y], it must be updated by a certain edge, that is, dis[y]=min{dis[xi]+vi}.
So, dis[y] can't be bigger, because dis[y]+1 must be greater than a certain dis[xi]+vi. . . .
Since it can't be bigger, it's the biggest solution. . .
The longest way is the same.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325652333&siteId=291194637