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

建议使用的浏览器:

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

5267:pog loves szh IV

题目描述
Pog plays a game with szh and this time he finds another tree, this tree is different from the previous one, all nodes of which have a weight! And the weight of the $i-th$ node is $a_i$.

Pog and Szh choose two different nodes on the tree, then pog walks to szh along the paths of the tree and records the weight. Because of too many nodes, pog only records the XOR of all weight of the nodes he passes for convenient.Due to szh's love for pog,szh wanders the sum of which pog records for any $n*(n-1)$ different combinations.

Because of tired of szh's corny pursuit, pog changes $a_A$ into $B$ at every moment, of course, szh must output the answer of all moment.
输入解释
Several groups of data (no more than $3$ groups,$n \geq 1000$).

In every group, two integers at first line are $n(2 \leq n \leq 10000)$ and $Q(1 \leq Q \leq 10000)$.

At the following line, $n$ integers are $a_i(0 \leq a_i < 32768)$.

At the following $n-1$ line, two integers are $b_i$ and $c_i$ at every line, it shows an edge connecting $b_i$ and $c_i$.

At the following $Q$ line, two integers are $A(1 \leq A \leq n)$ and $B(0 \leq B < 32768)$ at every line, it shows that changing $a_A$ into $B$.
输出解释
For each inquire to each group of data, output a line , which shows all the sum of which pog records in different combinations.
输入样例
5 5
1 2 3 4 5
1 2
1 3
2 4
2 5
1 3
2 4
4 4
5 3
2 1
输出样例
82
46
46
70
60
来自杭电HDUOJ的附加信息
Recommend hujie

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

题目来源 BestCoder Round #43

源链接: HDU-5267

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

共提交 0

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