XOR and MEX 题解
Gold14526
·
·
题解
容易发现,如果 f(a,x)=y,那说明 x\oplus y 没有在序列 a 中出现,那么 f(a,x\oplus y)=0,那么 x+f(a,x)=x+y,(x\oplus y)+f(a,x\oplus y)=x\oplus y,显然有 x\oplus y\le x+y,所以答案只会选 f(a,x)=0 的 x。
那么我要只要求让 f(a,x)=0 的最小的 x,也就是最小的没有在 a 中出现的数,也就是 a 的 \operatorname{mex},随便 O(n)。