# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
225297 | cgiosy | XOR (IZhO12_xor) | C++17 | 163 ms | 89208 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 <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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |