QTREE6  Query on a tree VI
You are given a tree (an acyclic undirected connected graph) with n nodes. The tree nodes are numbered from 1 to n. Each node has a color, white or black. All the nodes are black initially. We will ask you to perform some instructions of the following form:
 0 u: ask for how many nodes are connected to u, two nodes are connected if all the node on the path from u to v (inclusive u and v) have the same color.
 1 u: toggle the color of u (that is, from black to white, or from white to black).
Input
The first line contains a number n that denotes the number of nodes in the tree (1 ≤ n ≤ 10^{5}). In each of the following n1 lines, there will be two numbers (u, v) that describes an edge of the tree (1 ≤ u, v ≤ n). The next line contains a number m denoting number of operations we are going to process (1 ≤ m ≤ 10^{5}). Each of the following m lines describe an operation (t, u) as we mentioned above(0 ≤ t ≤ 1, 1 ≤ u ≤ n).
Output
For each query operation, output the corresponding result.
Example
Input 1: 5 1 2 1 3 1 4 1 5 3 0 1 1 1 0 1 Output 1:
5 1
Input 2: 7 1 2 1 3 2 4 2 5 3 6 3 7 4 0 1 1 1 0 2 0 3 Output 2: 7 3 3
Warning: large input/output data, be careful with certain languages
hide comments
zer0_h6cks:
20191211 09:11:39
Got AC finally!


Sigma Kappa:
20171016 23:40:53
Somehow, my solution with Segment Tree with lazy propagation gets WA, but when I replace the segment tree with a trivial array, it gets AC in ~4 secs. I do so wonder is there any bug in my implementation of SegTree? I tested it on many SPOJ problems, shouldn't be. Also tested my solution on a huge set of random cases... 
Added by:  xiaodao 
Date:  20131017 
Time limit:  1s5s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Own problem, CodeChef December Challenge 2013 