5302: I love tree
内存限制:256 MB
时间限制:15.000 S
评测方式:文本比较
命题人:
提交:16
解决:1
题目描述
Given a tree with n nodes and q operations, there are two kinds of operations.
1 a b : for a chain <a, b>, increase the value of x2 to the x-th point on this chain
for example the chain from a to b=(x1,x2,x3,x4,x5),after the operation,x1+=1,x2+=4,x3+=9,x4+=16,x5+=25
2 x :asks the value of x-th node
1 a b : for a chain <a, b>, increase the value of x2 to the x-th point on this chain
for example the chain from a to b=(x1,x2,x3,x4,x5),after the operation,x1+=1,x2+=4,x3+=9,x4+=16,x5+=25
2 x :asks the value of x-th node
输入
There is only one test case for this question.
The first line contains one integer n(1≤n≤105) .
The next n−1 line contains two integers u,v,which means that there is an edge between u and v.
The next line contains one integer q(1≤q≤105) .
The i-th of the following q lines is in one of the 2 formats:
1 a b (1≤a,b≤n)
2 x (1≤x≤n)
The first line contains one integer n(1≤n≤105) .
The next n−1 line contains two integers u,v,which means that there is an edge between u and v.
The next line contains one integer q(1≤q≤105) .
The i-th of the following q lines is in one of the 2 formats:
1 a b (1≤a,b≤n)
2 x (1≤x≤n)
输出
Each line output one integer represents the answer.
样例输入 复制
3
1 2
2 3
5
1 1 2
2 1
1 2 1
2 2
2 3
样例输出 复制
1
5
0