Link:
Http://codeforces.com/contest/617/problem/E
Code:
to structNode { + intL, R, id; - }Q[MAXN]; the * intN, M, K; $ intA[MAXN];Panax Notoginseng intPOS[MAXN]; - ll ANS[MAXN]; thell sum[2000007]; + A BOOLCMP (Node A, Node B) { the if(POS[A.L] = = POS[B.L])returnA.R <B.R; + returnPOS[A.L] <POS[B.L]; - } $ $ intL =1, R =0; -ll Ans =0; - the voidAddintx) { -Ans + = Sum[a[x] ^K];Wuyisum[a[x]]++; the } - Wu voidDelintx) { -sum[a[x]]--; AboutAns-= sum[a[x] ^K]; $ } - - intMain () { -Ios::sync_with_stdio (false), Cin.tie (0); ACIN >> n >> M >>K; + intSZ =sqrt (n); theRep (I,1, n +1) { -CIN >>A[i]; $A[i] ^= a[i-1]; thePos[i] = I/sz; the } theRep (I,0, M) { theCIN >> Q[I].L >>Q[I].R; -Q[i].id =i; in } theSort (q, q +m, CMP); thesum[0] =1; AboutRep (I,0, M) { the while(L < Q[I].L) del (L-1), l++; the while(L > Q[I].L) L--, Add (L-1); the while(R < Q[I].R) r++, add (R); + while(R > Q[i].r) del (r), r--; -Ans[q[i].id] =Ans; the }BayiRep (I,0, m) cout << Ans[i] <<Endl; the return 0; the}
Codeforces Round #340 (Div. 2) E. XOR and favorite number MO team algorithm