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

建议使用的浏览器:

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

5571:tree

题目描述
Giving a tree with weight on edges and weight on points, for every pairs of points $( i, j ) ( i < j )$, we can calculate the cost as $(a_i$ xor $a_j) \times dis(i,j)$, $dis(i,j)$ means the distance between point $i$ and point $j$.

There are $T$ operations, each operation the weight of a point will be modified. Please output the sum of cost for each pairs after every operations.
输入解释
Several test cases(about $3$)

For each cases, first come an integer, $n(1 \leq n \leq 30000)$,indicating the number of nodes in the tree.

Then follows $n$ integers $a_i ( 0 \leq a_i \leq 16383)$

Next $n - 1$ lines,input three numbers $A_i, B_i, C_i (0 \leq C_i \leq 100)$ per line,indicating a long for $C_i$ edge connecting $A_i$ and $B_i$.

Then input an integer $T(1 \leq T \leq 30000)$.

Next $T$ lines,input two numbers $D_i,E_i ( 1 \leq D_i \leq n, 0 \leq E_i \leq 16383)$,indicating the $aD_i$ is modified to $E_i$.
输出解释
For each cases, please output $T$ answers.
输入样例
5
1 2 3 4 5
1 2 3
1 3 4
2 4 5
2 5 5
5
1 2
2 4
3 2
4 1
5 5
输出样例
346
346
335
330
330
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5571

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

共提交 0

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