Submission #609103

# Submission time Handle Problem Language Result Execution time Memory
609103 2022-07-27T12:15:56 Z AliHasanli XORanges (eJOI19_xoranges) C++17
100 / 100
139 ms 8652 KB
#include <bits/stdc++.h>
using namespace std;
const int MAX = 200001;
int t[2][MAX];
int arr[MAX];

void inc(int id, int i, int dx) {
    for (; i < MAX; i |= i + 1) {
        t[id][i] ^= dx;
    }
}

int sum(int id, int i) {
    int res = 0;
    for (; i > 0; i = (i & (i + 1)) - 1) {
        res ^= t[id][i];
    }
    return res;
}

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
        inc(i & 1, i, arr[i]);
    }
    while (q--) {
        int qt, l, r;
        scanf("%d%d%d", &qt, &l, &r);
        if (qt == 1) {
            inc(l & 1, l, arr[l] ^ r);
            arr[l] = r;
        } else {
            if ((r - l + 1) % 2 == 0) {
                puts("0");
                continue;
            }
            printf("%d\n", sum(l & 1, r) ^ sum(l & 1, l - 1));
        }
    }
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d", &arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
xoranges.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d%d%d", &qt, &l, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 5 ms 468 KB Output is correct
14 Correct 4 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 8600 KB Output is correct
2 Correct 98 ms 8652 KB Output is correct
3 Correct 99 ms 8592 KB Output is correct
4 Correct 139 ms 8268 KB Output is correct
5 Correct 94 ms 8268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 5 ms 468 KB Output is correct
14 Correct 4 ms 448 KB Output is correct
15 Correct 96 ms 8600 KB Output is correct
16 Correct 98 ms 8652 KB Output is correct
17 Correct 99 ms 8592 KB Output is correct
18 Correct 139 ms 8268 KB Output is correct
19 Correct 94 ms 8268 KB Output is correct
20 Correct 109 ms 8308 KB Output is correct
21 Correct 125 ms 8408 KB Output is correct
22 Correct 88 ms 8328 KB Output is correct
23 Correct 93 ms 8316 KB Output is correct
24 Correct 120 ms 8260 KB Output is correct