# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13321 | dohyun0324 | XOR (IZhO12_xor) | C++98 | 2000 ms | 100420 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<stdio.h>
#include<map>
#include<string.h>
using namespace std;
map<int,int>ch;
int ans,p,len,n,x,a[250010],b[250010],sum[250010],dap[250010],t;
int main()
{
int i,j;
scanf("%d %d",&n,&x);
for(i=1;i<=n;i++) scanf("%d",&a[i]);
for(i=30;i>=0;i--){
if(x&(1<<i)){
t+=(1<<i);
for(j=1;j<=n;j++){
if((1<<i)&a[j]) b[j]+=(1<<i);
sum[j]=sum[j-1]^b[j];
}
}
else{
t+=(1<<i);
for(j=1;j<=n;j++){
if((1<<i)&a[j]) b[j]+=(1<<i);
sum[j]=sum[j-1]^b[j];
ch[sum[j]]=j;
}
for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]);
for(j=1;j<=n;j++) ch[sum[j]]=0;
t-=(1<<i);
}
}
for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]);
for(j=1;j<=n;j++) ch[sum[j]]=0;
for(i=1;i<=n;i++){
if(ans<dap[i]-i+1) ans=dap[i]-i+1, p=i;
}
printf("%d %d",p,ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |