[HNOI2014] road congestion

This is a no code of the blog. The purpose is to leave all metaphysics complexity algorithm has the complexity of the algorithm is guaranteed.

Original excerpt from thousands of fox _ genius  :

Fly approach should be A + segment tree. With A run short circuit k, for the first time must be given to go the shortest, followed by a short circuit will go to all the most updated answers. If this is the case simply is not enough, because all paths will be updated once. But we can easily find a message, assuming that the label points on the shortest path 0-the n- 0 - the n-, the answer must be 0-> u-> V-> the n- 0 - > U - > v - > the n-, U, v U , v in the shortest possible way (this also comes the problem solution), and u-> v U - > v and the shortest intersection is empty. And the answer will not have two discrete paths do not intersect and the shortest. So we ran a time of record A * opt O P T.
Opt = 0: IF (the next point is a point of the shortest path) OPT -> 0
   the else OPT ->. 1
opt =. 1: IF (the next point is the shortest path point) oPT -> 2
   the else oPT ->. 1
opt = 2: segment tree update interval.
For each point, if augmented over the left end point is the same, retaining only the first, because dis is certainly increasing, so for the same endpoint, each point will only be augmented to time. (Map or hash judgment) this crucial card that might otherwise be exponentially qwq. In this case in fact, logically speaking it should be is O (mlogm) about the.

 

Guess you like

Origin www.cnblogs.com/GreenDuck/p/11516940.html