Submission #938100

#TimeUsernameProblemLanguageResultExecution timeMemory
938100tombXOR (IZhO12_xor)C++17
0 / 100
1 ms344 KiB
#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 timeMemoryGrader output
Fetching results...