Describe
There are n nodes on a tree, numbered 1 to N, each with a weight of W. We will ask you to do something about this tree in the following form: I. Change u t: Changing the weight of the node U to t ii. QMAX U V: asks for the maximum weight of the node on the path from point u to v. Qsum U V: asks for the weights and values of the nodes on the path from point u to v. Note: Nodes on the path from point u to v include U and V itself.
Analysis
Learn the problems that can be done by the tree chain split.
- A query and an operation and a query maximum operation, the intermediate steps are different. Can write two functions, the return value is initialized when the time is not the same, qsum when initialized to 0, Qmax when the initialization when initialized to-inf.
- If you want to call a segment tree without a tree link (such as a change in the subject, because it is a single point of modification), the change is not the
x tid[x] new number of X. Because the number in the segment tree is re-edited.
Code
https://code.csdn.net/snippets/607983
The INF can be set 0x3f3f3f3f so that memset(0x3f) the initial value of the array is equal to. Better 0x3fffffff nature.--archon
A bunch of macros, write cooked very good. --archon
Statistics of bzoj-1036-Tree count