#P5063. [Ynoi Easy Round 2014] 置身天上之森
[Ynoi Easy Round 2014] 置身天上之森
Description
A segment tree is a special binary tree that satisfies the following properties:
Each node corresponds to an interval and has an integer weight.
The interval corresponding to the root is .
If a node corresponds to interval and , then its left child and right child correspond to intervals and , where .
If a node corresponds to interval and , then this node is a leaf.
If a node is not a leaf, then its weight equals the sum of the weights of its left child and right child.
Chtholly (ke duo li, 珂朵莉) needs to maintain a segment tree. The initial weights of the leaves are . Then operations will be performed:
Operation : given , for every (), add to the weight of the leaf corresponding to , and the weights of non-leaf nodes change accordingly.
Operation : given , ask how many nodes in the segment tree satisfy that the interval corresponding to this node is contained in , and its weight is less than or equal to .
Input Format
The first line contains two integers .
In the next lines, each line contains four integers , representing one operation, where indicates the operation type.
Output Format
For each operation with , output one line containing one integer, which is the answer.
3 3
1 2 3 9
2 1 2 1
2 1 3 1
1
1
Hint
Idea: zcysky.
Solution: nzhtl1477 ( solution ), ccz181078 ( solution ).
Code: nzhtl1477 ( code ), ccz181078 ( code ).
Data: nzhtl1477.
Constraints: for of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号