#ds702. DFS序练习1
DFS序练习1
DFS Order Exercise 1
Problem Description
You are given a tree with vertices, each carrying a point weight , with vertex as the root. You must answer operations:
1 x y: change the point weight of vertex to .2 x: query the sum of point weights of the subtree of , and the sum of point weights of the path from up to the root (both sums include vertex itself).
Input Format
The first line contains two integers ().
The next lines each contain two integers , denoting an edge between the two endpoints.
The next line contains integers ().
The next lines each describe one operation. It is guaranteed that .
Output Format
For each query operation, output two numbers: the two answers.
Sample Input
5 5
1 2
2 3
2 4
3 5
1 2 3 4 5
2 1
2 3
1 2 10
2 1
2 3
Sample Output
15 1
8 6
23 1
8 14