The Crazy Magic Tree
A variety of operations a hodgepodge of ghost animal data structure problems
First we notice that the shape of the tree is semi-random.
We can divide the tree into blocks, dividing the tree into chunks.
For each block we maintain an add tag that represents the increment
Maintain a vis mark indicating the amount of coverage
Note the decentralization of the mark and the processing between the two marks
Then we sort each block, and maintain the order within the block
This can be done for each query if it involves a complete block of two points
Otherwise brute force query
This time complexity is O (n*sqrt (n) *log (n))
Crazy color Sequence
Very old topic, if I get rid of mandatory online, I know there are five different methods.
The first way is that MO team
The second approach is to take the query offline after sorting the scan line + Tree array
The third approach is to calculate the position of each color last occurrence, within the block block of the Order + two points
The fourth approach is a tree-set tree, similar to the principle of chunking.
The fifth is the code that I write, we calculate the position of each color last occurrence of the pre
Then each query is equivalent to asking how many points [l,r] have a pre value of <l
And then it's the bare topic that can persist the line tree.
Cojs Crazy Magic Tree Crazy color sequence Puzzle report