UkgOA #1
Minimum Flips to Match Expected Binary Values in a Tree
估计中等可在线判题
You are given an undirected tree rooted at 0. Performing an operation on node u flips every node in u's subtree whose index has the same parity as u. Find the minimum number of operations to turn initial entirely into expected.
输入格式
Input N (1..100000), N−1 0-based edges, and two binary arrays initial and expected.
输出格式
Output the minimum number of operations.
样例 1
输入:
4
0 1
0 2
1 3
1 1 0 1
0 1 1 0
输出:
2
样例 2
输入:
5
0 1
1 2
0 3
1 4
1 0 1 1 0
1 1 0 1 1
输出:
3
样例 3
输入:
1
1
0
输出:
1