Submission #1092416

#TimeUsernameProblemLanguageResultExecution timeMemory
1092416juicyXOR (IZhO12_xor)C++17
0 / 100
14 ms30044 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif const int N = 25e4 + 5, M = 7500005, LG = 30; int n, k, node = 1; int a[N], nxt[M][2], lst[M]; void add(int x, int i) { int p = 1; for (int j = LG - 1; ~j; --j) { int c = x >> j & 1; if (!nxt[p][c]) { nxt[p][c] = ++node; } p = nxt[p][c]; lst[p] = min(lst[p], i); } } int qry(int x) { int m = 1e9, p = 1; for (int j = LG - 1; ~j; --j) { int c = x >> j & 1, d = k >> j & 1; if (!d && nxt[p][c ^ 1]) { m = min(m, lst[nxt[p][c ^ 1]]); } if (!nxt[p][c ^ d]) { return m; } p = nxt[p][c ^ d]; } return min(m, lst[p]); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; array<int, 2> res{}; memset(lst, 0x3f, sizeof(lst)); for (int i = 1; i <= n; ++i) { cin >> a[i]; a[i] ^= a[i - 1]; add(a[i - 1], i); int l = qry(a[i]); res = max(res, {i - l + 1, l}); } cout << res[1] << " " << res[0]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...