0916- simulation game

A

The previous article has proven detailed summary +

Confused questions, I may be bad math

B

This question has three relatively obvious nature.

1. The final route must start from the beginning through some plaid, backtrack to the starting point.

2. In order to maximize the value, if a loop section (repeated at some point along the walk), then there must be walked circulation section, and then pocket on the cycle section laps and then backtrack.

3. If there are circulating on the route section, the size of the circular section of some 2

I did not think the nature of 3, and then I explode on the spot leopard

C

The problem is immortal gods to do

Probably lca + dfs sequence + set

For any point x:

x lca and other points of maximum depth is x itself.

1. If the amount of the upward sub-tree is the point rooted x, then x is the deepest lca;

2. If there is no sub-tree located at a point upwardly amount x is the root, then find the FA [x] is the subtree rooted in the amount of up point,

lca is fa [x]. Otherwise, we find fa [fa [x]] as a sub-tree root, the amount of points up, then lca is fa [fa [x]]. .......

And so on. That is, try to find x "relatives" close relationship with the amount of points up.

to sum up

Score desirable: \ (40 + 40 + 50 = 130 \)

Actual Score: \ (40 + 50 + 0 = 90 \)

B bfs title fight fried (I think this question bfs can not do this)

Guess you like

Origin www.cnblogs.com/qwqq/p/11621085.html