AC一覧

## Problem Statement問題文

Given rooted tree of $N$ vertices. The root of tree is a vertex $0$. A value of vertex $i$ is $a_i$, and a parent of it is $p_i$. Process the following $Q$ queries in order:

• 0 $u$ $x$: $a_u \gets a_u + x$
• 1 $u$: Print the sum of values of subtree, whose root is $u$.

• 0 $u$ $x$: $a_u \gets a_u + x$
• 1 $u$: $u$ を根とする部分木の値の総和を出力

## Constraints制約

• $1 \leq N, Q \leq 500,000$
• $0 \leq p_i < i$
• $0 \leq a_i, x \leq 10^9$

## Input入力

$N$ $Q$
$a_0$ $a_1$ ... $a_{N - 1}$
$p_1$ $p_2$ ... $p_{N - 1}$
$\textrm{Query}_0$
$\textrm{Query}_1$
:
$\textrm{Query}_{Q - 1}$


### # 1

5 5
1 10 100 1000 10000
0 1 2 2
1 1
1 2
0 1 100000
1 0
1 3

11110
11100
111111
1000


Timelimit: 5 secs

Before submitting, please confirm terms and conditions