# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79895 | imeimi2000 | XOR (IZhO12_xor) | C++17 | 1272 ms | 41896 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 <cstdio>
#include <unordered_map>
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
int n, k;
int ansi, ansk = 0;
int a[250001];
int main() {
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; ++i) {
scanf("%d", a + i);
a[i] ^= a[i - 1];
}
if (k == 0) {
printf("1 %d\n", n);
return 0;
}
--k;
for (int i = 0; i < 30; ++i) {
if ((k >> i) & 1) continue;
int x = (k >> i) ^ 1;
unordered_map<int, int> mp;
for (int j = 0; j <= n; ++j) mp[a[j] >> i] = j;
for (int j = 0; j <= n; ++j) {
int mx = mp[(a[j] >> i) ^ x];
if (ansk < mx - j) ansk = mx - j, ansi = j + 1;
else if (ansk == mx - j && j + 1 < ansi) ansi = j + 1;
}
}
printf("%d %d\n", ansi, ansk);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |