bzoj#P1954. [PKU3764] The xor-longest Path
[PKU3764] The xor-longest Path
题目描述
In an edge-weighted tree, the xor-length of a path is defined as the xor sum of the weights of edges on :
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 nodes, can you find the xor-longest path?
给定一棵 个点的带权树,求树上最长的异或和路径。
输入格式
The input contains several test cases. The first line of each test case contains an integer , The following lines each contains three integers (, ), which means there is an edge between node and of length .
输出格式
For each test case output the xor-length of the xor-longest path.
4
1 2 3
2 3 4
2 4 6
7
样例说明
The xor-longest path is , which has length ().
提示
注意:结点下标从 开始到 。
数据规模与约定
对于 的数据,,。