1737.
Influence
时间限制 4000 ms
内存限制 256 MB
You are given a rooted tree with N vertices, numbered from 1 to n, the root is 1.
The weight of edges is 1, the value of vertices is 0 at the beginning.
There are 3 type of operation:
1 x : query the value of vertex x
2 x y : modify the weight of edge to y whose child node is x
3 x y : for every vertex i in the tree, value of it add ($y \cdot dis(x , i)$),
$dis(x , i)$ means the shortest distance between x and i in tree
输入数据
输出数据
For each operation 1 output one integer denotes the answer.
样例输入
复制
2
3
1 1
7
3 1 1
1 2
1 3
2 2 2
3 1 2
1 2
1 3
10
1 1 3 4 4 3 1 1 9
7
2 9 74
3 7 96
1 6
3 7 87
2 5 69
3 10 6
1 5
\n
\n
· \n
\n
· · \n
· \n
· \n
· · \n
· · \n
· \n
· \n
\n
· · · · · · · · \n
\n
· · \n
· · \n
· \n
· · \n
· · \n
· · \n
· \n
样例输出
复制
1
1
5
3
288
1425
\n
\n
\n
\n
\n
\n