SP2939 QTREE5 - Query on a tree V
Description
You are given a tree (an acyclic undirected connected graph) with N nodes. The tree nodes are numbered from 1 to N. We define dist(a, b) as the number of edges on the path from node a to node b.
Each node has a color, white or black. All the nodes are black initially.
We will ask you to perfrom some instructions of the following form:
- 0 i : change the color of i-th node(from black to white, or from white to black).
- 1 **v** : ask for the minimum dist(u, **v**), node u must be white(u can be equal to **v**). Obviously, as long as node **v** is white, the result will always be 0.
Input Format
N/A
Output Format
N/A