Educational codeforces Round E. Beautiful subarrays trie seek two XOR or value greater than or equal to K logarithm

Source: Internet
Author: User

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≤ lRn. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.