# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338524 | juggernaut | XOR (IZhO12_xor) | C++14 | 175 ms | 22508 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 250009
using namespace std;
int p[MAXN],n,X;
int tree[MAXN*30][2],sub[MAXN*30],nd;
void add(int x,int ind){
int now=0;
for(int i=29;i>=0;i--){
int bit=x>>i&1;
if(tree[now][bit])
now=tree[now][bit];
else{
tree[now][bit]=++nd;
sub[nd]=n+1;
now=tree[now][bit];
}
sub[now]=min(sub[now],ind);
}
}
int get(int i,int x,int now,int cur){
if(cur>=X)
return sub[now];
if(i<0 or cur+(1<<i+1)-1<X)
return n+1;
int bit=x>>i&1,ret=n+1;
for(int j=0;j<2;j++)
if(tree[now][j])
ret=min(ret,get(i-1,x,tree[now][j],cur+(j!=bit)*(1<<i)));
return ret;
}
int main(){
//freopen("file.in", "r", stdin);
scanf("%d%d",&n,&X);
for(int i=1;i<=n;i++){
scanf("%d",p+i);
p[i]^=p[i-1];
}
int a=1,b=1;
for(int i=1;i<=n;i++){
add(p[i-1],i);
int l=get(29,p[i],0,0);
if(i-l>b-a)
a=l,b=i;
}
printf("%d %d\n",a,b-a+1);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |