Tree query - MarisaOJ: Marisa Online Judge

Tree query

Time limit: 1000 ms
Memory limit: 256 MB
Given a tree with $n$ vertices. Each vertex initially has a weight of $0$. You are given $q$ queries, each of the following types: - `1 u d`: increase the weight of every vertex adjacent to vertex $u$ by $d$. - `2 u`: report the current weight of vertex $u$. ### Input - The first line contains two integers $n$ and $q$. - The next $n - 1$ lines each contain two integers $u$ and $v$, indicating an edge between vertex $u$ and vertex $v$. ### Output - For each query of type `2`, print the result (the weight of the vertex $u`). ### Constraints - $1 \le n,q \le 10^5$. - $1 \le u, v \le n$. - $1 \le d \le 10^9$. ### Example Input: ``` 3 2 1 2 1 3 1 1 1 2 3 ``` Output: ``` 1 ```