当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6962:I love tree

题目描述
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 $x^2$ 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\leq n\leq 10^5)$ .

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\leq q\leq 10^5)$ .

The i-th of the following $q$ lines is in one of the 2 formats:

$1$ $a$ $b$ $(1\leq a,b\leq n)$

$2$ $x$ $(1\leq x\leq 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

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6962

最后修改于 2021-10-23T19:10:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/524288K(Java/Others)