Submission #225297

#TimeUsernameProblemLanguageResultExecution timeMemory
225297cgiosyXOR (IZhO12_xor)C++17
100 / 100
163 ms89208 KiB
#include <bits/stdc++.h> using namespace std; struct iii { int l, r, k; }; int main() { ios::sync_with_stdio(0);cin.tie(0); int N, M, K=0, m=0, id=1; cin>>N>>M; vector<iii> T(N*30, {0, 0, INT_MAX}); for(int i=0, x=0; i<N;) { for(int p=1, d=30; d--;) { auto&[l,r,k]=T[p]; if(x&1<<d) p=r=r?:++id; else p=l=l?:++id; T[p].k=min(T[p].k, i); } int j=++i, t; cin>>t; x^=t; t=0; for(int p=1, d=30; d-- && p;) { auto[l,r,k]=T[p]; int a=x&1<<d, b=M&1<<d; if(!b) j=min(j, T[a?l:r].k); p=a^b ? r : l; t|=b; if(t>=M) { j=min(j, T[p].k); break; } } if(m<i-j) m=i-j, K=j+1; } cout<<K<<' '<<m; }

Compilation message (stderr)

xor.cpp: In function 'int main()':
xor.cpp:12:15: warning: unused variable 'k' [-Wunused-variable]
    auto&[l,r,k]=T[p];
               ^
xor.cpp:21:14: warning: unused variable 'k' [-Wunused-variable]
    auto[l,r,k]=T[p];
              ^
#Verdict Execution timeMemoryGrader output
Fetching results...