"Examination" weight

Correct answer is tree section.

First Kru minimum spanning tree.

Then consider each side of the tree and non-tree edges answer.

First, a non-tree edge, the non-tree edge links two points on a chain MST can be formed.

On this side of the chain's largest piece of -1 is the answer of this edge.

why.

Simulation of Kru. If this edge before that a tree words. This side of the two sets have not necessarily start and end links.

Since before the tree was a broken tree on the broken chain.

Then this edge will become the side of the tree.

Then the side of the tree.

Tree edges answer is even more simple and obvious point, our side will threaten the status of non-tree tree edge.

That might reach the front edge of a tree in a non-tree edge, then this edge will become the side of the tree.

So this will be a non-tree can update an entire chain of the answer tree.

For each side of the tree, the answer is a minimum value, if still INF, output -1, otherwise the output value of -1.

Then all of the above operations can be solved with a chain split tree.

We have solutions.

Guess you like

Origin www.cnblogs.com/Lrefrain/p/11566890.html