Submission #589088

#TimeUsernameProblemLanguageResultExecution timeMemory
589088promaXOR (IZhO12_xor)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; const int N = 250005; int n, x, a[N], pref[N]; int main() { /* freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); */ cin >> n >> x; pref[0] = 0; for (int i = 1; i <= n; i ++) { cin >> a[i]; pref[i] = (pref[i-1] ^ a[i]); } int l = 1, r = n, i, k = -1; while (l <= r) { int m = (l + r) / 2; int flag = 0; for (int j = 1; j + m - 1 <= n; j ++) { if ((pref[j+m-1] ^ pref[j-1]) >= x) { i = j; k = m; flag = 1; l = m + 1; break; } } if (!flag) r = m - 1; } cout << i << " " << k; return 0; }

Compilation message (stderr)

xor.cpp: In function 'int main()':
xor.cpp:39:18: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |     cout << i << " " << k;
      |                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...