Title: http://hzwer.com/3708.html
Analysis:
Similar to the idea of tree division, set F[x][i] means that the x is the root of all the points of the sub-tree, the distance from X is the number of points I, this can be preprocessed out
Then we consider each subtree's contribution to ans.
1. A chain with X as the starting point I,ans+=f[x][i]
2. Two different sub-trees with X as the starting point i,j:
If "XOR" is regarded as "and", then it is two subtree corresponding to the f[] multiplication (actually is the female function)
But here is the "XOR" Ah!! In fact, as long as the multiplication of the coefficients do not change, the index XOR a bit on the line
For example, normal multiplication: {1,3}*{1}== (x+3x^2) * (x) ==x^2+3x^3
Here is {1,3}^{1}== (x+3x^2) ^ (x) ==x^ (1^1) +3x^ (1^2) ==x^0+3x^3
[BZOJ3696] [FJSC2014] Compound (female function under an XOR rule)