bzoj#P3637. Query on a tree VI
Query on a tree VI
Description
You are given a tree (an acyclic undirected connected graph) with nodes. The tree nodes are numbered from to .
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 u
: ask for how many nodes are connected to , two nodes are connected if all the node on the path from to (inclusive and ) have a same color.1 u
: toggle the color of (that is, from black to white, or from white to black).
Input
The first line contains a number n denoted how many nodes in the tree (). The next lines, each line has two numbers describe a edge of the tree (). The next line contains a number denoted how many operations we are going to process (). The next lines, each line describe a operation as we mentioned above (, ).
Output
For each query operation, output the corresponding result.
5
1 2
1 3
1 4
1 5
3
0 1
1 1
0 1
5
1