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

建议使用的浏览器:

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

5173:GTY's game II

题目描述
GTY likes playing games with ZZF. But ZZF doesn't like to play with GTY because GTY is too stupid. This time GTY invites ZZF to play games again! To avoid being laughed at by ZZF, this time GTY takes you, GTY's assistant in the game( Because you are muchsmarter than GTY). ZZF likes painting, so she drew a tree on the papar. It's so beautiful that GTY almost forgot he had a game to play... Then ZZF said, 'I could play this game with you, but you have to answer the question correctly and quickly. Or I will give you a good-man card. 'After that she drew some nodes on the tree, each of them having a value. During the game ZZF will ask you a question or let you do an operation :
$0~u~v$ : query the sum of the values of the nodes in the route$ (u, v)$
$1~u~v$ : reverse the values of the nodes in the route$ (u, v)$
For GTY doesn't want to be given a good-man card, he needs you to help him.
输入解释
In the first line there are two numbers n, the number of the nodes, and m, the number of the operations. ( $ 1 \leq n, m \leq 80000 $ )
The next line contains n numbers which are the values of the nodes. ( $ 1 \leq val_i \leq 1000 $ )
The next $n - 1$ lines describe the tree. In each line there are two numbers u and v, meaning there is an edge between u and v. ( $ 1 \leq u, v \leq n $ )
The next $m$ lines describe the queries and the operations. Each line contains three numbers $op, u, v$. Their meanings are the same as the description above.
输出解释
For each query print the ans in one line.
输入样例
4 3
1 2 3 4
1 2
1 3
2 4
0 1 3
1 2 3
0 1 4
输出样例
4
8
来自杭电HDUOJ的附加信息
Recommend hujie

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

题目来源 BestCoder Round #29

源链接: HDU-5173

最后修改于 2020-10-25T23:20:24+00:00 由爬虫自动更新

共提交 0

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