#P1824C. LuoTianyi and XOR-Tree
LuoTianyi and XOR-Tree
No submission language available for this problem.
Description
LuoTianyi gives you a tree with values in its vertices, and the root of the tree is vertex .
In one operation, you can change the value in one vertex to any non-negative integer.
Now you need to find the minimum number of operations you need to perform to make each path from the root to leaf has a bitwise XOR value of zero.
A leaf in a rooted tree is a vertex that has exactly one neighbor and is not a root.
The first line contains a single integer () — the number of vertices in the tree.
The second line contains integers (), the -th number represents the value in the -th vertex.
Next lines describe the edges of the tree. The -th line contains two integers and () — the vertices connected by an edge of the tree. It's guaranteed that the given edges form a tree.
Print a single integer — the minimum number of operations.
Input
The first line contains a single integer () — the number of vertices in the tree.
The second line contains integers (), the -th number represents the value in the -th vertex.
Next lines describe the edges of the tree. The -th line contains two integers and () — the vertices connected by an edge of the tree. It's guaranteed that the given edges form a tree.
Output
Print a single integer — the minimum number of operations.
Note
The tree in the first example:

If we change the value in the vertex to , the value in the vertex to , and the value in the vertex to , then the tree will be ok.
The bitwise XOR from the root to the leaf will be .
The bitwise XOR from the root to the leaf will be .
The bitwise XOR from the root to the leaf will be .
The tree in the second example:

If we change the value in the vertex to , the value in the vertex to , and the value in the vertex to , then the tree will be ok.
The bitwise XOR from the root to the leaf will be .
The bitwise XOR from the root to the leaf will be .
The bitwise XOR from the root to the leaf will be .
The bitwise XOR from the root to the leaf will be .
In the third example, the only leaf is the vertex and the bitwise XOR on the path to it is , so we don't need to change values.
In the fourth example, we can change the value in the vertex to , and the value in the vertex to .
Here denotes the bitwise XOR operation.