# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81827 | mra2322001 | XOR (IZhO12_xor) | C++14 | 2045 ms | 25776 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>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)
#define bit(x, y) (((x) >> (y))&(1ll))
using namespace std;
typedef long long ll;
const int N = 250002;
int n, a[N], f[N], xo;
map <int, int> g;
void init(int b){
g.clear();
f0(i, n + 1){
int x = f[i] >> b;
g[x] = i;
}
}
int main(){
ios_base::sync_with_stdio(0);
scanf("%d%d", &n, &xo);
f1(i, n) scanf("%d", &a[i]), f[i] = f[i - 1]^a[i], g[f[i]] = i;
int res = 0, ans = 0;
f0(i, n + 1){
int cur = xo ^ f[i];
int x = g[cur] - i;
if(x > res) res = x, ans = i + 1;
}
for(int b = 29; b >= 0; b--){
if(bit(xo, b)) continue;
int now = (xo >> b);
now ++;
init(b);
f0(i, n + 1){
int x = f[i] >> b;
int cur = now ^ x;
int t = g[cur] - i;
if(t > res) res = t, ans = i + 1;
else if(t==res){
if(i + 1 < ans) ans = i + 1;
}
}
}
printf("%d %d", ans, res);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |