#Q58. 「一本通 2.3 练习 5」The XOR-longest Path
「一本通 2.3 练习 5」The XOR-longest Path
Description
Original problem from: POJ 3764
Given a weighted tree with nodes, find the longest XOR path on the tree.
Input Format
The first line contains an integer . The next lines each contain three integers , indicating an edge between and with length .
Output Format
Output a single integer representing the answer.
Sample 1
The longest XOR path is , with a length of .
Note: Node indices range from to .
Note: denotes the bitwise XOR of and .
4
1 2 3
2 3 4
2 4 6
7
Constraints & Hints
For of the data,