# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90060 | Yaroslaff | XOR (IZhO12_xor) | C++14 | 2 ms | 376 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 pb push_back
#define F first
#define S second
#define ll long long
//#define int ll
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC
using namespace std;
mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
const int M = 1e9 + 7;
const int FFTM = 998244353;
const int N = 2e5 + 7;
int n, a[N], x;
pair<int,int> f(int l){
pair<int,int> res;
int cur = 0;
for (int i = 0; i < l; i++)
cur ^= a[i];
if (cur >= x) return {1, 1};
for (int i = l; i < n; i++){
cur ^= a[i - l], cur ^= a[i];
if (cur >= x) return {1, i - l + 2};
}
return {0, 0};
}
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
cin >> n >> x;
for (int i = 0; i < n; i++)
cin >> a[i];
int l = 0, r = n, res = 0;
while (l <= r){
int m = (l + r)>>1;
if (f(m).F){
res = max(res, m);
l = m + 1;
}
else r = m - 1;
}
cout << f(res).S << ' ' << res;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |