#ds702. DFS序练习1

DFS序练习1

DFS Order Exercise 1

Problem Description

You are given a tree with nn vertices, each carrying a point weight wiw_i, with vertex 11 as the root. You must answer qq operations:

  1. 1 x y: change the point weight of vertex xx to yy.
  2. 2 x: query the sum of point weights of the subtree of xx, and the sum of point weights of the path from xx up to the root (both sums include vertex xx itself).

Input Format

The first line contains two integers n,qn, q (1≤n,q≤2×1051 \leq n, q \leq 2 \times 10^5).

The next n−1n - 1 lines each contain two integers u,vu, v, denoting an edge between the two endpoints.

The next line contains nn integers w1,w2,…,wnw_1, w_2, \dots, w_n (1≤wi≤1091 \leq w_i \leq 10^9).

The next qq lines each describe one operation. It is guaranteed that 1≤x≤n, 1≤y≤1091 \leq x \leq n,\ 1 \leq y \leq 10^9.

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

Constraints

  • 1≤n,q≤2×1051 \leq n, q \leq 2 \times 10^5
  • 1≤wi≤1091 \leq w_i \leq 10^9
  • 1≤x≤n, 1≤y≤1091 \leq x \leq n,\ 1 \leq y \leq 10^9