#P3044. 「一本通 2.3 练习 5」The XOR-longest Path

「一本通 2.3 练习 5」The XOR-longest Path

Description

**原题来自:[POJ 3764](http://poj.org/problem?id=3764)** 给定一棵 $n$ 个点的带权树,求树上最长的异或和路径。

Input Format

第一行一个整数 $n$,接下来 $n-1$ 行每行三个整数 $u,v,w$,表示 $u,v$ 之间有一条长度为 $w$ 的边。

Output Format

输出一行一个整数,表示答案。
4
1 2 3
2 3 4
2 4 6
7

Hint


数据范围:对于 $100\%$ 的数据,$1\le n\le 10^5,1\le u, v \le n,0 \le w < 2^{31}$

Source

LibreOJ