#P7710. [Ynoi2077] stdmxeypz
[Ynoi2077] stdmxeypz
Problem Description
You are given a rooted tree with edge weight and root at node . Each node has a node value initially equal to . The distance between two nodes is defined as the length of the simple path between them in the tree. You need to support two types of operations:
1 a x y z: For all nodes in the subtree of whose distance to modulo equals , add to their node values.
2 a: Query the node value of node .
Input Format
The first line contains two integers , meaning the tree has nodes and there are operations.
The second line contains integers. The -th integer denotes the parent of node in the tree.
Then follow lines, each in the form 1 a x y z or 2 a, representing the operations above.
Output Format
For each operation of type , output one line with one integer representing the answer.
5 5
1 1 2 1
1 1 5 4 1
1 1 4 1 5
1 2 1 0 4
2 3
2 1
5
0
Hint
Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477
Constraints: For of the testdata, , , , , , .
Translated by ChatGPT 5