1#include <bits/stdc++.h>2 3 using namespacestd;4 Const intN =1<< -;5 structnode6 {7 intL,r,id;8 }q[n];9 Ten intAns[n]; One Long LongAnswer[n]; A Long LongFlag[n]; - intA[n]; - BOOLCMP (node X,node y) the { - if(ans[x.l]==ANS[Y.L]) - returnx.r<Y.R; - returnans[x.l]<ANS[Y.L]; + } - intn,m,k; + intL =1, R =0; A Long Longans=0; at voidAddintx) - { -ans+=flag[a[x]^K]; -flag[a[x]]++; - } - voidDelintx) in { -flag[a[x]]--; toans-=flag[a[x]^K]; + } - intMain () the { * $scanf"%d%d%d",&n,&m,&k);Panax Notoginseng intSZ =sqrt (n); - for(inti =1; I <= N; i++){ thescanf"%d",&a[i]); +A[i] = a[i-1]^A[i]; AAns[i] = i/sz; the } +flag[0] =1; - for(inti =1; I <= m; i++) $ { $scanf"%d%d",&q[i].l,&Q[I].R); -Q[i].id =i; - } theSort (q+1, q+m+1, CMP); - for(inti =1; I <= m; i++)Wuyi { the while(l<q[i].l) - { WuDel (L-1); -l++; About } $ while(l>q[i].l) - { -l--; -Add (l1); A } + while(r<Q[I].R) the { -r++; $ Add (R); the } the while(r>Q[I].R) the { the del (R); -r--; in } theAnswer[q[i].id] =Ans; the } About for(inti =1; I <= m; i++) the { theprintf"%lld\n", Answer[i]); the } + return 0; -}
MO Team Algorithm Template