luogu#P5063. [Ynoi Easy Round 2014] 置身天上之森
[Ynoi Easy Round 2014] 置身天上之森
Background

If, I mean if,
I were going to die in five more days,
could you treat me a bit more gently?

Such good luck.
Sacrificing only me will be enough.
That is how it is.

Are you willing to grant my last wish now?
Um... well... for example... right.

Like letting you kiss me.
Would you?

Before I disappear,
I hold the wish that I do not want to disappear.
I hope someone will remember me.
I hope to leave behind a bond.
I wish for this—what is wrong with that?

Problem 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