제출 #106707

#제출 시각아이디문제언어결과실행 시간메모리
106707PajarajaXOR (IZhO12_xor)C++17
100 / 100
247 ms23420 KiB
#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); }

컴파일 시 표준 에러 (stderr) 메시지

xor.cpp: In function 'int main()':
xor.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&x);
  ~~~~~^~~~~~~~~~~~~~
xor.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&np); tr^=np;
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...