[Solution] XOR Tree Codeforces Solution 2022 | Solution Codeforces
You are given a tree consisting of vertices. A number is written on each vertex; the number on vertex is equal to .
Recall that a simple path is a path that visits each vertex at most once. Let the weight of the path be the bitwise XOR of the values written on vertices it consists of. Let's say that a tree is good if no simple path has weight .
You can apply the following operation any number of times (possibly, zero): select a vertex of the tree and
replace the value written on it with an arbitrary positive integer. What is the minimum number of times you have to apply this operation in order to make the tree good?
The first line contains one integer () — the number of vertices.
Three Doors Codeforces Solution 2022
Also Try Minecraft Codeforces Solution
Recover an RBS Codeforces Solution
Rorororobot Codeforces Solution
Multiset of Strings Codeforces Solution
The second line contains integers , , ..., () — the numbers written on vertices.
Then lines follow, each containing two integers and () denoting an edge connecting vertex with vertex . It is guaranteed that these edges form a tree.
Print a single integer — the minimum number of times you have to apply the operation in order to make the tree good.
No comments:
Post a Comment