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

建议使用的浏览器:

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

3764:The xor-longest Path

题目描述

In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edges on p:

__poj_jax_start___{xor}length(p)=\oplus_{e \in p}w(e)__poj_jax_end___{xor}length(p)=\oplus_{e \in p}w(e)

⊕ is the xor operator.

We say a path the xor-longest path if it has the largest xor-length. Given an edge-weighted tree with n nodes, can you find the xor-longest path?  

输入解释

The input contains several test cases. The first line of each test case contains an integer n(1<=n<=100000), The following n-1 lines each contains three integers u(0 <= u < n),v(0 <= v < n),w(0 <= w < 2^31), which means there is an edge between node u and v of length w.

输出解释
For each test case output the xor-length of the xor-longest path.
输入样例
4
0 1 3
1 2 4
1 3 6
输出样例
7
提示

The xor-longest path is 0->1->2, which has length 7 (=3 ⊕ 4)


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3764

最后修改于 2020-10-29T07:10:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536