[The diameter of the tree] Fire

  We need to think of the path must lie diameter.

  If the above law found, then the processing directly to the out diameter, the problem is converted into a sequence, monotone bit can be run queue.

  However, very light goose my knowledge, can not figure out why.

  

  Length of set diameter D $ $

  If this path is completely outside diameter, $ ans> = d / 2 $

  If this path is completely in diameter, $ ans <= d / 2 $

  If part of this path in diameter, assuming the diameter away from point to point $ P $ $ Q $ point (will be appreciated that the diameter of that edge as long walk but may take other side a)

    Since the distance P must be greater than the diameter of the other end of the PQ $ $, even if the point P $ $ $ Q $ from, this part of the distance is reduced, but not so small maximum distance

    That answer is not better than the $ P $ directly off point

  It is possible to find a path directly in diameter.

 

  Just to find the most Emperor said intermediate diameter that path can (i.e., maximum value of minimum two to two of unsubstituted)

  It seems very reasonable (Giant)

  

  Because for a non-optimal solution in terms of its gap with the optimal solution can be found in:

    Non-optimal solution in a side chain longer than the optimal solution.

    Non-optimal solution discarded chain ends is longer than the optimal solution.

  The first can not happen, because if the program did not choose the best piece of long side chains, will lead to a multi-part to extend to a side chain, the answer is more bad

  Therefore, the optimal solution shortest chain discarded =

  

  I have to say the emperor is still too huge.

Guess you like

Origin www.cnblogs.com/yxsplayxs/p/11454531.html