XorTree
시간 제한2초메모리 제한256 MB
한 번의 연산으로 트리의 한 경로에 속한 모든 간선에 같은 값을 XOR할 수 있을 때, 모든 간선 값을 0으로 만드는 최소 연산 횟수를 구한다.
문제
You are given a tree with vertices. The vertices are numbered through , and the edges are numbered through . Edge connects vertex and , and has a value . You can perform the following operation any number of times: choose a simple path and a non-negative integer , then for each edge that belongs to the path, change by executing ( denotes ).
Your objective is to have for all edges . Find the minimum number of operations required to achieve it.
입력
Input is given in the following format:
출력
Find the minimum number of operations required to achieve the objective.
제한
, , . The given graph is a tree, all input values are integers.
힌트
In Sample 1, the objective can be achieved in three operations, as follows: first, choose the path connecting Vertex , and , then, choose the path connecting Vertex , and ; lastly, choose the path connecting Vertex , and .