#P4551. 最长异或路径
最长异或路径
Description
Given a weighted tree with nodes, indexed from to . Find the maximum value among the XOR of all paths in the tree.
An XOR path is the XOR of all edge weights along the unique path between two nodes in the tree.
Constraints .
Input Format
The first line contains an integer , the number of nodes.
The next lines each contain , meaning there is an edge between node and node with weight .
Output Format
One line with a single integer, the answer.
4
1 2 3
2 3 4
2 4 6
7
Hint
When the two nodes are and , the value is , which is the maximum.
Translated by ChatGPT 5
京公网安备 11011102002149号