#P6329. 【模板】点分树 / 震波

【模板】点分树 / 震波

Background

This is a template problem, with no raprap.

Problem Description

On a piece of land, there are nn cities. They are connected by n1n-1 undirected edges, forming a tree. The distance between two adjacent cities is 11. The value of city ii is valueivalue_i.

Unfortunately, earthquakes often happen on this land, and as time goes on, the values of cities may also change.

You need to process mm operations online:

0 x k means an earthquake happens, with the epicenter at city xx and an affected radius of kk. All cities whose distance to xx is at most kk will be affected. The economic loss of this earthquake is the sum of the values of all affected cities.

1 x y means the value of city xx becomes yy.

To ensure the online nature of the program, in each operation, xx, yy, and kk must be decrypted by XOR with the output of your previous query. If there has been no output before, the previous output is considered to be 00 by default.

Input Format

The first line contains two positive integers nn and mm.

The second line contains nn positive integers. The ii-th number denotes valueivalue_i.

The next n1n-1 lines each contain two positive integers uu and vv, indicating an undirected edge between uu and vv.

The next mm lines each contain three numbers, describing the mm operations.

Output Format

Output several lines. For each query, output one positive integer per line as the answer.

8 1
1 10 100 1000 10000 100000 1000000 10000000
1 2
1 3
2 4
2 5
3 6
3 7
3 8
0 3 1
11100101

Hint

Constraints

For 100%100\% of the testdata, 1n,m1051\leq n,m\leq 10^5, 1u,v,xn1\leq u,v,x\leq n, 1valuei,y1041\leq value_i,y\leq 10^4, 0kn10\leq k\leq n-1.

upd: The sample constraints are different from the real constraints. Please use the constraints given in the hint.

Notes

Source: BZOJ3730.

Translated by ChatGPT 5