# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
225285 | cgiosy | XOR (IZhO12_xor) | C++17 | 5 ms | 512 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, id=1;
cin>>N>>M;
vector<int> A(N+1);
for(int i=1; i<=N; i++) cin>>A[i], A[i]^=A[i-1];
int K=0, m=0;
vector<iii> T((N+1)*31, {0, 0, INT_MAX});
for(int i=0; i<=N; i++) {
int x=A[i], j=i+1;
for(int p=1, d=31; 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);
}
for(int p=1, d=31; d-- && p;) {
auto[l,r,k]=T[p];
if(x&1<<d) {
if(M&1<<d) p=l;
else j=min(j, T[l].k), x^=1<<d, p=r;
} else if(M&1<<d) x^=1<<d, p=r;
else j=min(j, T[r].k), p=l;
if(x>=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... |