2019-9-10 do title record

Title in three, one is $ gyfan $ talked about class, one is to do a year before the $ yyb $ A $ aysn $ is doing now. And my level between the second and third.

1] [BZOJ1926 millet millet shelves (prefix and Chairman of the tree):

In the case of multi-row multi-line, we want to maintain a multi-dimensional and prefix.

$ Value_ {i, j, k} $ $ from (1,1) to $ $ (i, j) $ $ a matrix of values> = the sum of the number of k $

$ Num_ {i, j, k} $ $ from (1,1) to $ $ (i, j) $ $ a matrix of values> = number of values ​​of k $

Then direct-half of the minimum number of pages of a book on it.

In the case of a line, so why do not we do it? Because of this no less than open to engage in an array ($ n \ le 500,000 $), so we used the President of trees on the range-half (Chairman of tree length $ \ le 1000 $, good chicken ah).

But think about it, in fact, do not need so that we can put pressure on the first dimension, such as a $ 10 per share $ $ i $ a sequence, so that not only able to open array, when queried more than a constant $ 10 $ on it.

Essentially, this question can range prefix and the reason is the Chairman of the tree is relatively small.

2, the LCA] [BZOJ3626 (chain split tree, Link-Cut Tree)

$ Aysn $ when research study tour told me immortal question, but then nest too weak, got nothing to understand, said the $ yyb $ may have to learn ah.

It took 10 minutes ruined a formula, is found to find the $ Chair trees strand [l, r] number $ number, from the prefix and again to get on, and then the prefix count again from top to bottom and, but because it is the merger of plus tree line, so complexity will leave, optimization method is also very simple, direct next to the time to get on the global playing a $ 1 + $ labeled lazy, and give themselves to make a $ - $ 1 lazy numerals, so even if the depth of the bottom-out, and then open a global request directly at the segment tree to reduce it. (May mouth Hu is false, it may also be a better way, who knows?)

Evening saw $ yyb $, and $ aysn $ find method is the same, is considered a dynamic process, for the interval $ [l, r] $ which we find all the elements, put them all point to the root of the $ + 1 $, then the query $ z $ to and the root is the number (not hard to imagine, here with me decadent a thing, but I put it complicated, in fact, not recorded specifically who the information, you need only the number of records as $ zhhx $ say Chinese chess, the state of compression $ dp $ instead record $ 0 $ how many, $ 1 $ how many , $ 2 $ how many, and second, how many were pressed ... ) and then found that the contribution can be reduced, i.e., the $ [l, r] $ into $ [1, r] $ and $ [1, l-1] $, we split the chain as long as each current tree $ I $ points to the root of all $ 1 + $, $ z $ lookup value and then needs it.

Obviously, $ aysn \ and \ yyb $ approach better, I need to refuel.

3, [shop] BZOJ4012

Come to grips with, but come.

All points online, without modification, to find the right tree $ [l, r] $ $ X to the distance and $.

Well done offline, then the discrete weights off, the $ [l, r] $ into $ [1, r] $ and $ [1, l-1] $, consider a data structure to support the insertion point and a query all point to point and distance.

Such questions obviously unrooted trees turn rooted tree, we maintain all point to the root of the distance and, if the root into $ x $ point, for all points on the root $ x $, denoted by $ i $ (not about rigorous, $ i + 1 $ $ I $ is the father), there $$ ans + = (- 2dis [i] + dis [x]) (siz [i] -siz [i-1]) $$, then demolition phase, and the $ X $ relationship has only proposed, direct calculation; and the I $ I $ $ $ related in position. On it (say good abstract ah, but I have no other other way), then that is so split tree chain, the chain modify and query like the previous question

Really Japanese dog, and written above all false, really is very simple, do not consider together, one by one, considered separately. $$ ans = \ sum_ {i = 1} ^ {n} {dis_i + ndis [x] -2dis [LCA (x, i)]} $$, and then use a push above method, each chain directly recorded covered like a number of times (this is the LCA $ $ seeking violence, a point above the point of coloring, and the first direction point encountered another color dot is their $ LCA $), and then for online, the chain split the tree line tree can be persistent. In this way time and space are two of the $ log $. (Found unused condition less degree of $ 3 $)

See also practice problem solution dotted tree (limit degree), $ yy $ can look at the next class.

4, BZOJ2006 [] [] super piano NOI2010

Bare sucker garbage problem.

The method used and the twelve provinces [exam] XOR dumplings exactly the same, so I retired sucker title, if the spot to do it, I can that day into the province $ 7 $, $ 8 $ name, $ day2 $ will certainly not will the collapse. I write on the test results in a $ 4 $ hours or did not write it, this is the life? Once, on my final exam in the ninth grade in the examination into the well, therefore I was carried away, and finally blew in the test when, on the middle of August. I also think that it was a success added to the test in that time, but had no chance, I think I should be glad that such a mistake is not the last.

Just can persist $ trie $ Chairman tree into the tree.

Amazingly, I came up with that title directly on the examination room, and this is my question under $ aysn $ prompt (He said this question and exclusive dumplings or similar) was thought out. Code may be force to improve, but the thinking has declined it. Trade-off.

5, network management] [BZOJ1146

Chairman of the tree with the tree repair.

Count On A Tree set a $ bit $.

How set? Anyway, I feel very magical, I would like to be sure I can not think.

I think so: each is a segment tree maintenance information to its own roots, but also along the father jumped $ lowbit (x) $ bit if the query, then modify it? Would not it be put in that position following each chain are modified, as the complexity of not just fake it.

The solution to a problem is very magical, full use of the contributions of addition and subtraction, the first tree chain split, obtained first class $ dfs $ order, we will build on the first class suffix array $ dfs $ sequence, or the same a collection of routines to include in the $ i $ $ i, i-lowbit (i), (i-lowbit (i)) - information lowbit (i-lowbit (i)) ... $, to modify the time of the $ start [x] $ modifications, to $ end [x] + 1 $ anti modified so that there is something of the impact of changes in the sub-tree, and then query only check $ start $, I still do not understand why this is of sleep you may soon know.

upd2019.9.11: sitting up it, just in the bath will understand, this is the second class of $ dfs $ sequence, a sequence that is in parentheses, just put some of this together should be reduced to a right parenthesis together, it does not affect the results of .

6] [BZOJ4556 string (suffix array, Chairman of the tree)

In Beijing immortals Hotel toilet inside, $ aysn $ Fairies do question, and I in the toilet $ yy $ one yourself out of the question, as if with the substring child relationship string, like a suffix automata do, I I forgot that night thinking of what title, only in retrospect Beijing's small sister, good to see ah. But $ CTS $ and $ APIO $ has become the last time we meet. . . .

Question is a good question, but my brain is really not turn up, what might not want to come out.

Obviously half the length, the beginning of a string of unlawful removed (as range), to give a range for the height $ $ $ taken along min $ array (as sequences), there is certainly an interval, we It is to check these two sections have no pay.

$ RMQ $ + calculated binary "taken along a section $ $ min", then the tree corresponds to two segments, the determined interval to see there is no difference of $ 0 to $.

7, [funny] SYCOJ279 ♂ tree

Water problems, do not write.

8、【HDU5919】Sequencell

First convert the precursor to see this question.

Then find the equivalent of the difference between the first and the second tree $ R & lt $ $ l-1 $ tree's $ <l $ number, then we bipartite out an intermediate position, see if it is brought into the median test.

But now we want to optimize (two $ log $), find this feature might not take full advantage of the Chairman of the tree (Chairman of the tree can check the interval, but this investigation left interval total is $ 0 $, waste), because an element has one and only a prefix, a prefix also has one and only one suffix, so this is probably a relationship arrangement, we can turn it upside down, so that correspond directly to the $ l $ a tree, then check $ l..r $, in half on the range, you can do a $ log $ a.

9、【CF813E】Army Creation

Thinking good question.

First, the precursor conversion.

$ Times precursor to the precursor = $ k.

10、【CF484E】Sign on Fence

$ Yyb $ speaking and $ aysn $ immortal title is a sort routine, I can only $ orz $ a.

The smallest maximum, half of the answers, the answers are treated as less than $ 0 $, the answers are deemed greater than $ 1 $, then it is to make $ [l..r] $ longest string of $ 1 is equal to greater than $ k $ $.

Chairman of the tree, insert size by weight, multi-segment tree to maintain some of the information (middle, left, right), every half an answer, check [l..r] is greater than of equal to $ k $. This is two of the $ log $.

Because Luo Gu solution to a problem the first to say that this problem can do a $ log $, so most people do are two $ log $, so I can be received.

11、【BZOJ2653】Middle

And the last question is a routine, binary answer , the less the answers are considered $ 0 $, to greater than answers are considered $ 1 $, the number if there is some range $ 0 $ more than $ 1 $ $ 1 $ or as many , which is $ 1 $ number is divided by the total number of $ 2 $, then the half of the answer is feasible.

Should be treated as less than or equal $ $ -1, of greater than $ 1 + $ considered, then find $ [a, b] $ maximum sub-segment and a right and $ [c, d] $ left sub-segment, and the maximum. Again, after half an answer, simply to determine what is an interval, is not a point, the problem often points (best value) becomes feasible solution after seeking a-half, and the problem becomes seeking a maximum range.

Chairman of the tree and then maintain it.

12, [] lined up JSOI2018

First of all, obviously, after the set, everyone the same relative position.

I mainly want to find a rank $ k $, let $ a [k] $ walked right $ l + k-1 $, and $ a [k + 1] $ $ l + k $ went to the left, that is, say, $ a [k] $ is the dividing line.

I.e., $ a [k] \ le l + k-1 $ and $ k $ maximum.

We then R & lt $ $ $ l-1 $ and the segment tree singled out on the binary weights, $ t2 [x] .cnt-t1 [x] .cnt $ $ K $ is, the range and scope of the current is two points out of $ a [k] $ range.

13, [XOR] TJOI2018

Baby stunned.

Originally thought to be a god linear base, and only later discovered that a number of XOR, so it becomes $ 0-1 \ trie $ sucker the subject.

In the case of the sub-tree, DFS run about $ $ sequence, and submit $ start [x] -1 $ and $ end [x] $ differencing two segment tree, then two points, where the chain is made directly down from the prefix and (this operation just to see me when $ Count \ on \ a \ tree $, I was shocked, because I thought it was gonna split the chain tree, but now handy) determined $ u, v, lca [u , v], fa [lca (u, v)] $ to four.

Guess you like

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