# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
938100 | tomb | 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;
#define MAXN 250000
#define ll long long
ll a[MAXN];
int viable(int k, int n, ll x){
ll val = 0;
int j = 0;
for (int i = j; i < k; i++)
val ^= a[i];
if (val >= x) return j;
while (++j + k <= n)
{
ll rm = a[j - 1];
for (int i = 30; i >= 0; i--)
{
if (rm & (1 << i) && !(val & (1 << i)))
val |= (1 << i);
else if (rm & (1 << i) && val & (1 << i))
val ^= (1 << i);
}
val ^= a[j + k - 1];
if (val >= x)
return j;
}
return -1;
}
int main(){
int n; ll x;
cin >> n >> x;
for (int i = 0; i < n; i++) cin >> a[i];
ll lo = 0, hi = n;
int idx = -1;
while (lo < hi){
int mid = (lo + hi + 1) / 2;
int res = viable(mid, n, x);
// cout << lo << endl;
if (res != -1)
lo = mid, idx = res;
else
hi = mid - 1;
}
cout << idx + 1 << " " << lo << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |