2019-9-12 do title record

1, Peaks enhanced version (Kruskal tree reconstruction, President of Tree)

$ Kruskal $ remodeling template theme tree.

$ Kruskal $ reconstructed tree: In China Unicom merger of the two blocks of time, to build a new point, when the original two yuan on behalf of his father, as a representative of the new China Unicom yuan block.

When queried jump the farthest reach of the ancestors on the leaves, check the $ k $ in $ dfs $ large order which leaves on the line.

2, [ LOJ # 6073] from (Chairman of the tree)

$ + $ Chain split tree may be persistent routines.

3, [ BZOJ4771] colorful tree (Chairman of the tree)

Good name and studious of the topic.

According to the idea of ​​a virtual tree, we carry out the same color point, DFS $ $ sort order, and then at each point $ 1 + $, $ adjacent points at the LCA $ $ $ -1, so we arbitrarily long check sub-tree and, you know subtree in the number of colors.

If you do not offline, we directly inserted into the sequence by depth-first search tree line, tree and child maintenance. The tree line to become President of the tree, you can line up.

4, [ BZOJ5304] [HAOI2018] covering string (suffix array, President tree, multiplication)

Clam provincial election is immortal title.

Obviously greedy left to right to be elected on the election.

$ Sa $ number of established trees chairman, range is its original position.

He asked when the first $ rmq + $-half of interval, find the first legitimate, then the Chairman of the tree again find a successor, which is $ O (n / | P | * logn) $ when $ | P | $ is small time is not enough.

When the $ P \ le 50 $, we can pre-answer. For each direct $ | P | $ build a tree, each of the precursor to its position (a position of $ X $, $ rearwardly such that | P | string and the current position is formed after the bit rearwardly $ | P | bit strings are equal to not cross) side of the father, we find the first valid position Chairman tree, and then look down a long chain, can be pretreated.

5, [BZOJ4408] [FJOI2016] mysterious number (Chairman tree maintenance greedy)

If there is only one asking, how do we do?

We first row a sequence, if not $ 1 $, $ 1 $ is the mysterious number, if you have $ 1 $, $ 2 $ we should suspect the number is not mysterious, if not the next $ 2 $, it is not.

But we found that this is false, because it can also come back a $ 1 $, and then makes up two $ 1 $ 2 $ a $.

In this case, every time we just put less than equal to $ 1 $ is found, then look at the next one is not $ sum + 1 $, if not, it is not, and if so, explain $ [1..2sum + 1] $ It is possible, directly to the $ sum $ becomes $ 2sum + 1 $. This process is of a $ log $

Asked many times, then find a tree with the President of the precursor instead of ordering, plus a $ log $, a total of $ log $ is two.

Such data structures maintained the greedy first question from the start with the simplest greedy, and then start from the second data structure. To say, I began to think of this question with the President of trees to maintain partition information is not enough.

6] [BZOJ4242 kettle (Kruskal reconstruction tree, BFS)

Visual inspection is $ IOI $ title ah.

First, it is clear that the two most value to check on the minimum spanning tree bottleneck.

$ Dijkstra $ staining on it, see the specific [JXOI2018] travelers.

7, [ BZOJ3712] Fiolki (disjoint-set reconstruction Tree)

Built a $ Krustra $ reconstruct the tree, then we know that a large depth priority response, high priority is first reacted with the depth.

According to this dual-key sort, the remaining amount of maintenance each time, and then turn to do it.

8, [ BZOJ2460] element (greedy, linear-yl)

It is to find some number, insert linear group, are successful, and maximize their sum.

Order a first row, followed by a linear group can be inserted.

In addition, I think the $ aysn $ fairy game title, the condition that the title and the "if and only if there is not a non-empty set, those elements number of ore Bitwise XOR and equal" to use is the same, that is all can successfully insert all the elements, that is to say, if I did this question, it is likely to make the road race title.

Guess you like

Origin www.cnblogs.com/shxnb666/p/11516518.html