Maintain subtree information using link/cut trees In the tutorial of [problem:1172E], I didn't write things on how to maintain subtree information, because I thought it was a popular trick. However, through [user:tmwilliamlin168,2019-06-12]'s [comment](/blog/entry/67511?#comment-518361), I realized that this trick may be not so common in other countries, so I decided to write a blog on it.
This blog will tell you how to maintain subtree information using LCT, with solutions on some problems, so you should know LCT before reading this blog.
## Main Idea
The main idea is simple: record the sum of information of "virtual subtrees", where the "virtual subtrees" refers to the subtrees except the one in the Splay.

In the picture, $1$, $2$, $6$, $10$ are in a Splay, while $8$ and $12$ are in another. The "virtual subtrees" of $1$ is $3$ and $4$, the "virtual subtrees" of $4$ is $7$ and $8$, the node $8$ has no "virtual subtree".
You need to update the i...
^= xorp[stot]; xorsum ^= xorp[stot]; break; case 3, ); void pushdown(int x); int id, n, m, sta[N], top, sx[M], sy[M], stot; ull
xorp[M],xorsum; int, int id, n, m, sta[N], top, sx[M], sy[M], stot; ull xorp[M], xorsum;
Full text and comments »