E. Beautiful Subarrays
One day, ZS the coder wrote-a array of integers a with elements a1, a2, ..., an.
A subarray of the array a is a sequence al, al + 1, ..., a R for some integers (l, R) such that 1≤ l ≤ R ≤ n. ZS the coder thinks that a subarray of a are beautiful if the bitwise XOR of all the elements in the Subarr Ay is at least k.
Help ZS The coder find the number of beautiful subarrays of a!
Input
The first line contains integers n and k (1≤ n ≤106, 1≤ k ≤10< C8>9)-the number of elements in the array a and the value of the parameter k.
The second line contains n integers ai (0≤ a I ≤109)-the elements of the array a.
Output
Print the only integer c -the number of beautiful subarrays of the array a.
Examples
input
3 1
1 2 3
Output
5
Test Instructions:Give you a sequence of n number, ask you how many intervals of the difference or value greater than or equal to KThe
following:For each prefix we insert in trie, it is good to ask the current prefix with an XOR value greater than or equal to the previous prefix.
#include <bits/stdc++.h>using namespacestd;Const intMAXN = 2e7+6;structtri{intch[maxn][2]; intSZ[MAXN]; inttot; voidinit () {memset (ch,0,sizeof(CH)); memset (SZ,0,sizeof(SZ)); Tot=2; } voidInsertintx) {intu=1; sz[u]++; for(intI= -; i>=0; i--) { intp = (x>>i) &1; if(!ch[u][p]) ch[u][p]=tot++; U=CH[U][P]; sz[u]++; } } int Get(intXinty) {intu=1; Long LongAns =0; for(intI= -; i>=0; i--) { intp = (x>>i) &1^1; intQ = (y>>i) &1; if(q==0) ans+=sz[ch[u][p]],u=ch[u][p^1]; Elseu=Ch[u][p]; if(u==1)returnans; } returnans+Sz[u]; }}t;intMain () {t.init (); intn,k; scanf ("%d%d",&n,&k); intPre =0; Long LongAns =0; T.insert (0); for(intI=1; i<=n;i++) { intX;SCANF ("%d",&x); Pre^=x; Ans+=t.Get(PRE,K); T.insert (pre); } cout<<ans<<Endl; return 0;}
Educational codeforces Round E. Beautiful subarrays trie seek two XOR or value greater than or equal to K logarithm