제출 #13345

#제출 시각아이디문제언어결과실행 시간메모리
13345dohyun0324XOR (IZhO12_xor)C++14
100 / 100
1774 ms123220 KiB
#include<stdio.h> #include<unordered_map> #include<string.h> using namespace std; unordered_map<int,int>ch; int ans,p,len,n,x,a[250010],b[250010],sum[250010],dap[250010],t,r; 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--){ r=1<<i; t+=r; if(x&r){ for(j=1;j<=n;j++){ if(r&a[j]) b[j]+=r; sum[j]=sum[j-1]^b[j]; } } else{ for(j=1;j<=n;j++){ if(r&a[j]) b[j]+=r; 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-=r; } } for(j=1;j<=n;j++) ch[sum[j]]=j; for(j=1;j<=n;j++) dap[j]=max(dap[j],ch[sum[j-1]^t]); 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 timeMemoryGrader output
Fetching results...