Meaning of the questions: a tree, point to ask each ancestor nodevToinofc[v]−c[u]/dis(v,u)ofm i nvalue.
The third question exam yesterday, is already seen on the convex hull maintenance, but fordfsBack when the convex hull of how to maintain the violence will only get stack maintenance (but it seems that for the time complexity of random dataO(nlo g2n)), However positive solution approach is to use a persistent stack.
In fact, the persistence stack is a tree, back to back operation is equivalent to the ancestors, while adding a new nodein, Following a directly connected state of the node, and then multiplying the direct-half (new position), to find the optimal nodev, And can persist in the stackinTovThe section of the path, in fact, the addition of normalinThe need to pop those elements of the stack, so that you can directly multiply-half to find the optimal solution, directly connected to that point below.
Multiplying two points: sweep from high to binary status, the node compares the current optimal multiplication nodeinversusinFathervWho better, ifvBetter, remains unchanged binary (this period because he could still be the optimal solution), then assign it as the optimal nodevOtherwise, it is a bit lower, continue toinDoubled.