logo AlgoBeat OnlineJudge
登录 注册

#101954. [BZOJ 1954] Pku3764 The xor-longest Path

内存限制:64 MiB 时间限制:1000 ms 标准输入输出
题目类型:传统 评测方式:文本比较
上传者: 匿名

题目描述

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.

样例

样例输入 #1

4
1 2 3
2 3 4
2 4 6

样例输出 #1

7

样例说明

The xor-longest path is , which has length ().

数据范围与提示

注意:结点下标从 开始到

对于 的数据,