#P5314. [Ynoi2011] ODT
[Ynoi2011] ODT
Description
You are given a tree where each edge has weight , and each node has a weight.
Support two operations:
1 x y z: Add to the weights of all nodes on the simple path from to .2 x y: Query the -th smallest node weight among all nodes whose distance to node is less than or equal to .
Input Format
The first line contains two integers .
The second line contains integers, the weight of each node.
Then follow lines, each containing two integers indicating that there is an edge between and .
Then follow lines, each in the form 1 x y z or 2 x y, as described above.
Output Format
For each operation of type , output one line with one integer, the answer.
It is guaranteed that the answer exists for every query.
5 5
3 4 3 1 3
1 2
1 3
2 4
3 5
2 1 3
2 1 1
1 1 1 1
2 1 3
1 4 1 1
4
3
4
Hint
- Idea: nzhtl1477.
- Solution: nzhtl1477 ( solution ), negiizhao ( solution ), ccz181078 ( solution ).
- Code: nzhtl1477 ( code ).
- Data: nzhtl1477 ( partially uploaded ).
Subtask 1: .
Subtask 2: the tree is a chain.
Subtask 3: .
Subtask 4: .
Subtask 5: .
Constraints: For of the testdata, , the value added in each update , the initial node weights .
Translated by ChatGPT 5
京公网安备 11011102002149号