luogu#P2137. Gty的妹子树
Gty的妹子树
Background
I once heard you amid the strings and songs.
The clapboard's sound shatters, half like a scene from an opera.
Dance pavilions and singing stages are blown away by the wind.
Deep in the years, a wisp of lingering echo remains...
Gty shen (xian) ben (chong) has never lacked girls...
He came under a "girl tree" and found that each girl has a beauty value...
Because Gty is very philosophical, he is only interested in girls whose beauty value is greater than a certain number.
He wants to know how many girls in some subtree have beauty value greater than .
A girl's beauty value may change...
A new girl may appear on the tree...
Problem Description
Maintain a rooted tree with nodes initially (the root is ), with node labels , and each node has a weight .
Support the following operations:
0 u xQuery the number of values strictly greater than in the subtree rooted at .1 u xSet the weight of node to .2 u xAdd a node whose index is "current number of nodes in the tree + 1", with parent and weight .
This problem is strictly online.
All input must be XORed with to obtain the actual input.
Here is the answer to the previous query, with initial .
Input Format
The first line contains a positive integer , the initial number of nodes.
The next lines each contain two integers , representing an undirected edge in the tree.
The next line contains integers , the initial weight of each node.
The next line contains a positive integer , the number of operations.
The next lines each contain three integers , describing one operation.
Output Format
For each operation with , output one line containing an integer, as described above.
2
1 2
10 20
1
0 1 5
2
2
1 2
10 20
1
0 1 10
1
Hint
Constraints
For of the testdata, , , .
Translated by ChatGPT 5