# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38915 | Talant | XOR (IZhO12_xor) | C++14 | 0 ms | 4360 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 fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;
int n,x;
int a[N],p[N];
int t[N * 4];
int id,k = -1;
void build (int v = 1,int tl = 1,int tr = n) {
if (tl == tr)
t[v] = p[tl];
else {
int tm = (tl + tr) >> 1;
build (v + v,tl,tm);
build (v + v + 1,tm + 1,tr);
t[v] = max(t[v + v],t[v + v + 1]);
}
}
int get (int l,int r,int v = 1,int tl = 1,int tr = n) {
if (tl > r || tr < l)
return -inf;
if (l <= tl && tr <= r)
return t[v];
int tm = (tl + tr) >> 1;
return max(get(l,r,v + v,tl,tm),get(l,r,v + v + 1,tm + 1,tr));
}
int main () {
scanf ("%d%d", &n,&x);
for (int i = 1; i <= n; i ++) {
scanf ("%d", &a[i]);
p[i] = (p[i - 1] ^ a[i]);
}
build ();
for (int i = 1; i <= n; i ++){
int l = i,r = n;
int cur = (p[i - 1] ^ x);
while (r - l > 1) {
int m = (r + l) >> 1;
if (get(m,n) >= cur)
l = m;
else
r = m;
}
if (get(r,n) >= cur)
l = r;
int o = 0;
if (get(l,n) < cur)
o = 0;
else
o = l - i + 1;
if (k < o)
id = i,k = o;
}
cout << id << " " << k << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |