# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085502 | Sunbae | XOR (IZhO12_xor) | C++17 | 1 ms | 344 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;
const int N = 1e5 + 5, inf = 1e9 + 7;
int qs[N], cp[N<<1], m = 0, bit[N<<1];
int pos(int x){ return upper_bound(cp, cp+m, x) - cp;}
void upd(int i, int val){ for(; i<=m; i+=i&-i) bit[i] = min(bit[i], val);}
int qry(int i){ int res = inf; for(; i; i-=i&-i) res = min(res, bit[i]); return res;}
signed main(){
int n, x; scanf("%d %d", &n, &x);
for(int i = 0; i<n; ++i){
scanf("%d", qs+i);
if(i) qs[i] ^= qs[i-1];
cp[m++] = qs[i];
cp[m++] = (x ^ qs[i]);
}
sort(cp, cp+m); m = unique(cp, cp+m) - cp;
fill(bit, bit+m+1, inf);
int mx_len = 0, mn_st = n;
for(int i = 0; i<n; ++i){
int Qry = qry(pos(qs[i]));
if(Qry < inf){
int len = i - Qry, st = Qry + 1;
if(len > mx_len) mx_len = len, mn_st = st;
else if(len == mx_len && st < mn_st) mn_st = st;
}
upd(pos(x ^ qs[i]), i);
}
++mn_st;
printf("%d %d", mn_st, mx_len);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |