2019 Summer Jinhua training Day5 tree data structure

Autistic training Day5

Tree data structure

Pre-knowledge

  • Dotted rule
  • Side partition
  • Tree chain split
  • LCT
  • Top Tree

LCT time complexity

Every segment tree query is strictly $ \ log the n- \ (. However splay maintain a continuous period of time, if each query point can be reduced, then the access number range is shared equally \) O (1) $ is. (??)

So with splay LCT is a maintenance log, and the segment tree maintenance are two log.

hide and seek

How good side partition, divide and conquer what point ......

Each point to open a sub-tree heap maintain the farthest point, to open a large heap maintain the value of the farthest point of the first two sons, to open a stack to maintain a global maximum, then just do.

Because each side of the divide and conquer only need to merge two sub-trees, so a lot of good writing.

bzoj2566

Each color is maintained separately.

bzoj3730

Each point Fenwick tree maintenance distance \ (len \) the right point and then rampage dotted tree.

Why can array the tree? Maximum \ (DEP \) is less than equal to the size of subtree, the point of partition and the size of the subtrees is \ (n-\ log n-\) .

Township fantasy strategy game

See blog.

Ynoi2011 D1T3

Mo + rollback segment tree merger team, but probably fake.

When each query tree found in dotted shallowest point, so that it is in communication with the fast and do it as root.

Then consider a point \ (I \) , if the \ (I \) to the root \ (min, max \) in (\ [l, r]) \ inside, then \ (I \) to within a communication fast . This is something similar to a number of two-dimensional points.

Then bring the color limitations, what is similar to a number of three-dimensional points.

Each point on things above pretreatment, offline what is \ (O (n \ log ^ 2 n) \) a.

floj307/CF1010F

Consider \ (O (n ^ 2) \) approach, it is found in a no brain DP: set \ (f_ {x, i} \) represents consideration \ (X \) subtree got \ (I \) number scheme communication block size, and promiscuity. Generating function is represented by \ (F_X = X \ Prod (+ f_v. 1) \) .

Chain sectional acceleration, the size of each of the light and sons are \ (n-\ log n-\) , do a one heavy chain.

Set \ (F_ i (x) \ ) represents consideration son weight generating function, \ (A_i (X) \) represents the weight without considering the son generation function.

Then there is $ F_i (x) = (F_ {i-1} (x) +1) A_i (x) x $, partition FFT.

After the expansion seems to be the formula that \ (\ SUM \ Limits _ {i = 1} ^ the n-\ Prod \ limits_ J = {i} ^ the n-B_j \) , the partition can be found FFT engage them, gone.

Ynoi2011 D2T3

Can root partition, pay attention to modify the time there will only be $ O (\ sqrt {n}) $ a point next to a big point, it can be violent.

Partition chain, each light point maintain only son, and then modify the time would only need to modify the header data structure of the heavy chain, then \ (O (n-\ log ^ n-2) \) .

Only light maintenance every son should be a routine.

UOJ191

The tree built out operation, plus point is to go to the son, the father jump point is deleted, the query is to ask the maximum value on a strand.

The answer is clearly on the convex hull, the question now is how to maintain the convex hull.

The most naive approach is to split the tree chains, each heavy chain and a segment tree maintenance convex hull is so \ (O (n \ log ^ 3 n) \) a. Note that the horizontal axis is not monotonous, it is necessary to maintain a balanced tree.

Hop heavy chain was found to have a property: as long as the current heavy chain is not the last one, then point to query must be a prefix.

Since it is a prefix then it can be off-line, then each of the heavy chain above are done, can a \ (\ log \) .

Finally, it is the overall complexity \ (O (n-\ log ^ n-2) \) .

A title

Two actions: modification point right, find a maximum priority value block communication.

Is a dynamic DP, directly engage.

LCT

Due to the LCT access is shared equally, it can not be persistent.

However, there are strict single \ (\ log n \) dynamic tree, however, will not.

A title

Can a_i $ (selected sub-tree all the leaves of the cost, ask the \) \ minimum cost x $ sub-tree leaves selected.

There is a simple violent DP: $ f_x = \ min (a_x, \ sum f_v) $.

Heavy chain split, transfer equation becomes $ f_i = \ min (a_i, f_ {i + 1} + b_i) $.

This is seen as a conversion to $ (A, B) \ (represented by \) X \ rightarrow \ min (A, B + X) $, and then found that the conversion can be merged:
\ [\ min (C, \ min (A , x + b) + d)
= \ min (\ min (c, a + d), x + b + d) \] and obviously also supports associative law, it is possible to maintain the segment tree. After the split sleeve to the tree chain \ (O (n \ log ^ 2 n) \) a.

If maintenance with LCT, then the reverse operation due to the presence of additional value to record in turn transform a little bit difficult to write, but the complexity is $ O (n \ log n) $.

A title

Dp_ set {I $, X} \ (to represent \) I \ (when the value \) X \ (, the winner who is right to left and DP, each find only a value change position, so we get a \) O (qn) $ approach. This approach is not very optimize ......

Found a property: every game will have at most one person hands-on, hands bound and then into an own number.

So before i $ \ (individuals only come up with less than or equal \) number of i $.

Then even edge: $ I \ (toward \) (I-a_i) n-% \ (even if side \.) (I-a_i) n-% \ $ GE I do not even then.

This forms a forest.

Then consider a DP: set \ (dp_ {x} \) means that if fa_x come $ \ (so \) X $ will change. If there is a son, then it is 0 is 1, otherwise 1.

Finally consider 0, if so $ dp_0 = 1 $ 0 wins, 0 otherwise is the son of which is the smallest number 1 point win.

Consider modifying the operation, it was found that dynamic DP, a maintenance LCT.

CodeChef Pushflow

Maximum flow is minimum cut, the cut side of the tree or the minimum cut or cut two rims.

If the cutting edge of the ring, then certainly to cut the minimum value, the minimum can be directly lost, added to the other edge.

Can directly engage with the round side tree, I probably learned a round square white tree ......

WineDAG's prevention

A tree, the right point point increase, the weight on the inverting path, the maximum interrogation path, a minimum value.

Normal LCT can not do, because splay in the LCT is based on the depth of weights.

This problem can maintain two splay, it is a form of splay, the other weights splay, the sequence preorder to-one correspondence.

Thus modification can be inverted without changing the value of the splay tree form directly above the right, so done.

CF1137F

Will not / kk

When \ (x \) in \ (y \) before it is deleted? So that the maximum weight of the root point, if and only if \ (X \) is not \ (Y \) of ancestors, and \ (X \) of the sub-tree does not exceed the maximum \ (Y \) is the maximum subtree .

Each point record each son to father node weights.

So what happens once up operation? Root + equivalent to a change chain cover. LCT cover strand can be viewed as the access operation.

So for every one inside the LCT splay, maintaining its weight in the global rank, then the query when you look at the point where the splay rank, together with their position in the splay of.

A title

Three point set to \ (A, B, C \) , satisfies \ (AB, BC \) constitutes a tree, \ (A \) inner side is not connected.

Random Q \ (i, j \) to \ (B \) numbering less \ (I \) a, \ (C \) numbering less \ (J \) point delete, \ (A \) the probability is still connected.

Descending enumeration \ (i \) , look at the biggest \ (j \) makes still connected. Clearly monotonicity, may then two pointers.

How to judge it?

Suppose enumerating \ (I \) after the \ (\ C) are deleted one by one point, the latest point in time of communication. Consider connectivity is a spanning tree propped up, so we only need to maintain maximum spanning tree delete time.

Then enumerate back to front \ (i \) time will continue to add some edges are not removed, that is the right value of \ (\ infty \) side, then fucks LCT can.

Guess you like

Origin www.cnblogs.com/p-b-p-b/p/11305264.html