#P2166. Gty的超级妹子树【数据疑似有误】

Gty的超级妹子树【数据疑似有误】

Description

Maintain a rooted tree with nn initial nodes (the root is 11). Nodes are labeled 11 to nn, and each node has a weight wiw_i. The tree may become a forest.

Support the following operations:

  • 0 u x Query the number of values strictly greater than xx in the subtree rooted at uu.
  • 1 u x Set the weight of node uu to xx.
  • 2 u x Add a new node whose id is the current number of nodes plus 11, with parent uu and weight xx.
  • 3 u Delete the edge between uu and its parent, and make uu the root of its connected component.

This problem is strictly online.

All input u,xu, x must be XORed with last\text{last} to get the real input, where last\text{last} is the previous query’s answer, and initially last=0\text{last} = 0.

Input Format

The first line contains a positive integer nn, the initial number of nodes.

The next n1n - 1 lines each contain two integers u,vu, v, indicating an undirected edge in the tree.

The next line contains nn integers wiw_i, the initial weight of each node.

The next line contains a positive integer mm, the number of operations.

The next mm lines each describe one operation, as specified above.

Output Format

For each operation with op=0\text{op} = 0, output one line with a single integer, as described in the problem statement.

2
1 2
10 20
1
0 1 5

2

Hint

Constraints

For 100%100\% of the testdata, 1n,m1051 \le n, m \le 10^5, 1un1 \le u \le n, 0wi,x<2310 \le w_i, x < 2^{31}.

Translated by ChatGPT 5