제출 #523515

#제출 시각아이디문제언어결과실행 시간메모리
523515lukameladzeXOR (IZhO12_xor)C++14
0 / 100
1 ms460 KiB
# include <bits/stdc++.h> #define f first #define s second #define pb push_back #define int long long using namespace std; const int N = 3e5 + 5; int n,x,a[N],pref,idx,sf[N],posri,le,mx,sz,idd,val; map <int, int> fix[31]; void go(int lee , int rii ){ sz = rii - lee + 1; if (sz >= mx) { le = lee; mx = sz; } } main() { cin>>n>>x; for (int i = 1; i <= n; i++) { cin>>a[i]; } for (int i = 30; i >= 0; i--) { if ((1LL<<i)&x) { idx = i; break; } pref += (1<<i); } for (int j = idx; j >= 0; j--) { fix[j][0] = n + 1; } for(int i = n; i >= 1; i--) { // if (i == 1) cout<<le<<" "<<mx<<endl; sf[i] = sf[i + 1] ^ a[i]; //if (i == 2) cout<<sf[i]<<" "<<(int)(pref&sf[i])<<endl; if ((pref&sf[i])) { le = i; mx = n - i + 1; if (!idd) idd = i; int val = 0; for (int j = idx; j >= 0; j--) { if ((1<<j)&sf[i]) val += (1<<j); fix[j][val] = max(fix[j][val],i); } continue; } posri = idd - 1; sz = posri - i + 1; if (sz >= mx) { le = i; mx = sz; } int haveto = 0; for (int j = idx; j >= 0; j--) { if ((1<<j)&x) { if (!((1<<j)&sf[i])) haveto += (1<<j); //if (i == 1) cout<<j<<" " <<haveto<<endl; continue; } if ((1<<j)&sf[i]) { if (fix[j][haveto]) go(i, fix[j][haveto] - 1); haveto += (1<<j); //if (i == 1) cout<<j<<" "<<haveto<<endl; continue; } if (i == 1) cout<<j<<" "<<haveto<<endl; if (fix[j][haveto + (1<<j)]) go(i, fix[j][haveto + (1<<j)] - 1); } //if (i == 1) cout<<haveto<<endl; if (fix[0][haveto]) { go(i,fix[0][haveto] - 1); } int val = 0; for (int j = idx; j >= 0; j--) { if ((1<<j)&sf[i]) val += (1<<j); fix[j][val] = max(fix[j][val],i); } } cout<<le<<" "<<mx<<endl; }

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

xor.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...