I feel quite anoyed with this problem
how can i count the number of MEX(simple path u to v) = m ( u,v is the same with v,u) on a tree rooted at 1?
and other query is swap the value of node u and node v
Related note: can i have some properties of MEX functions, i have some:
- If the set of numbers want to accquire the MEX = x, it must atleast have x+1 elements without a single element = x
Sorry for bad english









Auto comment: topic has been updated by Haught_Veath (previous revision, new revision, compare).
here is the answer for your question. i used that here
for finding mex in a set you can use segment tree with min operation: if x is not in set then seg[x] = x otherwise seg[x] = INF. mex is equal to minimum of whole segment.
thanks a lots, i just wonder around this problem for 2 weeks
can i ask if the problem ask for countinng the number of pair(u,v) such that mex(u,v) = M(M is given)
mex(u,v) is mex of the simple path
pair(u,v) is the same with pair(v,u)
1527D