# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1070830 | 2024-08-22T19:14:05 Z | matthew | XORanges (eJOI19_xoranges) | C++17 | 96 ms | 8784 KB |
#include <stdio.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); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 436 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 96 ms | 8784 KB | Output is correct |
2 | Correct | 69 ms | 8532 KB | Output is correct |
3 | Correct | 69 ms | 8656 KB | Output is correct |
4 | Correct | 73 ms | 8380 KB | Output is correct |
5 | Correct | 73 ms | 8276 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |