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

建议使用的浏览器:

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

5589:Tree

题目描述
There is a tree, whose vertices are labeled by 1, 2, …, N. They are connected by N–1 edges. Each edge has a weight.For any two vertices u and v, f(u,v) is xor(exclusive-or) sum of weights of all edges on the path from u to v.There are Q queries,for each query,giving you a interval [l,r], you should calculate the number of pairs (u,v) such that f(u,v) > M ($l\leq u < v \leq r$) 。
输入解释
There are multiple test cases.
For each case contains 3 integers N, M and Q on a line.$(1\leq N , M , Q\leq 50000)$
Each of the next N - 1 lines contains three space separated integers a, b and c denoting an edge between a and b, whose weight is c.$(1\leq a, b\leq N,0\leq c\leq 50000)$
Each of the next Q lines contains two integers l and r.$(1\leq l\leq r\leq N)$
输出解释
For each query,output the answer in a line.
输入样例
5 10 3
1 2 13
2 3 15
2 4 17
2 5 8
1 5
2 4
3 3
输出样例
6
3
0
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5589

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

共提交 0

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