# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1070836 | 2024-08-22T19:21:52 Z | matthew | XORanges (eJOI19_xoranges) | C++17 | 76 ms | 8436 KB |
#include <stdio.h> #include <assert.h> const int MAXN = 200'000; int v[MAXN + 1]; // poate fi optimizat la un singur N de memorie int aib_par[MAXN + 1]; int aib_impar[MAXN + 1]; void pointUpdate(int *aib, int pos, int delta, int n) { while(pos <= n) { aib[pos] ^= delta; pos += pos & -pos; } } int prefixQuery(int *aib, int pos) { int res = 0; while(pos > 0) { res ^= aib[pos]; pos &= pos - 1; } return res; } static inline int rangeQuery(int *aib, int l, int r) { return prefixQuery(aib, r) ^ prefixQuery(aib, l - 1); } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif int n, q, i, l, r, type, pos, val; scanf("%d%d", &n, &q); for(i = 1; i <= n; i++) { scanf("%d", &v[i]); pointUpdate((i & 1) ? aib_impar : aib_par, i, v[i], n); } for(i = 0; i < q; i++) { scanf("%d", &type); if(type == 2) { scanf("%d%d", &l, &r); if((r - l) & 1) { printf("0\n"); } else { printf("%d\n", rangeQuery((l & 1) ? aib_impar : aib_par, l, r)); } } else { scanf("%d%d", &pos, &val); pointUpdate((pos & 1) ? aib_impar : aib_par, pos, v[pos] ^ val, n); v[pos] = val; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 428 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 428 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 604 KB | Output is correct |
12 | Correct | 2 ms | 604 KB | Output is correct |
13 | Correct | 2 ms | 604 KB | Output is correct |
14 | Correct | 2 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 65 ms | 3924 KB | Output is correct |
2 | Correct | 68 ms | 3924 KB | Output is correct |
3 | Correct | 74 ms | 3920 KB | Output is correct |
4 | Correct | 59 ms | 3936 KB | Output is correct |
5 | Correct | 64 ms | 3920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 428 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 604 KB | Output is correct |
12 | Correct | 2 ms | 604 KB | Output is correct |
13 | Correct | 2 ms | 604 KB | Output is correct |
14 | Correct | 2 ms | 604 KB | Output is correct |
15 | Correct | 65 ms | 3924 KB | Output is correct |
16 | Correct | 68 ms | 3924 KB | Output is correct |
17 | Correct | 74 ms | 3920 KB | Output is correct |
18 | Correct | 59 ms | 3936 KB | Output is correct |
19 | Correct | 64 ms | 3920 KB | Output is correct |
20 | Correct | 76 ms | 8436 KB | Output is correct |
21 | Correct | 67 ms | 8272 KB | Output is correct |
22 | Correct | 67 ms | 8276 KB | Output is correct |
23 | Correct | 64 ms | 8276 KB | Output is correct |
24 | Correct | 69 ms | 8412 KB | Output is correct |