# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106707 | Pajaraja | XOR (IZhO12_xor) | C++17 | 247 ms | 23420 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define MAXN 250007
using namespace std;
int t,sn[2][30*MAXN],mn[30*MAXN],x,n,arr[MAXN];
void ubaci(int s,int d,int b,int ind)
{
if(d==-1) return;
int z=((1<<d)&b)>>d;
if(!sn[z][s]) {sn[z][s]=++t; mn[sn[z][s]]=ind;}
ubaci(sn[z][s],d-1,b,ind);
}
int poredi(int s,int d,int b)
{
if(d==-1) return mn[s];
int z=((1<<d)&b)>>d,sol=MAXN;
if(!(x&(1<<d)) && sn[1-z][s]) sol=mn[sn[1-z][s]];
if(sn[z][s]) sol=min(sol,poredi(sn[z][s],d-1,b));
return sol;
}
int main()
{
scanf("%d%d",&n,&x);
int mx=0,mnd,tr=0;
ubaci(0,29,0,0);
for(int i=1;i<=n;i++)
{
int np;
scanf("%d",&np); tr^=np;
int kn=i-poredi(0,29,tr^x);
if(kn>mx) {mx=kn; mnd=i-kn+1;}
ubaci(0,29,tr,i);
}
printf("%d %d",mnd,mx);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |