#P6329. 【模板】点分树 / 震波
【模板】点分树 / 震波
Background
This is a template problem, with no .
Problem Description
On a piece of land, there are cities. They are connected by undirected edges, forming a tree. The distance between two adjacent cities is . The value of city is .
Unfortunately, earthquakes often happen on this land, and as time goes on, the values of cities may also change.
You need to process operations online:
0 x k means an earthquake happens, with the epicenter at city and an affected radius of . All cities whose distance to is at most 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 becomes .
To ensure the online nature of the program, in each operation, , , and 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 by default.
Input Format
The first line contains two positive integers and .
The second line contains positive integers. The -th number denotes .
The next lines each contain two positive integers and , indicating an undirected edge between and .
The next lines each contain three numbers, describing the 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 of the testdata, , , , .
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