Submission #1022526

# Submission time Handle Problem Language Result Execution time Memory
1022526 2024-07-13T16:36:42 Z A_M_Namdar XORanges (eJOI19_xoranges) C++14
100 / 100
99 ms 8792 KB
#include <bits/stdc++.h>
using namespace std;

const long long N = 2e5 + 10, SQ = 500;
long long n, q, a[N], dp[2][N];

long long ans(long long l, long long r) {
    if (((r - l) & 1) == 0)
        return 0;
    long long res = 0;
    long long l1 = ((l + SQ - 1) / SQ) * SQ, r1 = (r / SQ) * SQ;
    if (r1 > l1) {
        for (long long i = l; i < l1; i += 2)
            res ^= a[i];
        for (long long i = l1; i < r1; i += SQ)
            res ^= dp[l & 1][i / SQ];
        for (long long i = r1 + (l & 1); i < r; i += 2)
            res ^= a[i];
    }
    else
        for (long long i = l; i < r; i += 2)
            res ^= a[i];
    return res;
}

void input() {
    cin >> n >> q;
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
        dp[i & 1][i / SQ] ^= a[i];
    }
}

void solve() {
    for (long long i = 0; i < q; i++) {
        long long op;
        cin >> op;
        if (op == 1) {
            long long j, v;
            cin >> j >> v;
            j--;
            dp[j & 1][j / SQ] ^= a[j] ^ v;
            a[j] = v;
        }
        else {
            long long l, r;
            cin >> l >> r;
            cout << ans(l - 1, r) << '\n';
        }
    }
}

int main() {
    ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
    input();
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 7768 KB Output is correct
2 Correct 80 ms 8792 KB Output is correct
3 Correct 82 ms 8788 KB Output is correct
4 Correct 99 ms 8532 KB Output is correct
5 Correct 97 ms 8528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
15 Correct 95 ms 7768 KB Output is correct
16 Correct 80 ms 8792 KB Output is correct
17 Correct 82 ms 8788 KB Output is correct
18 Correct 99 ms 8532 KB Output is correct
19 Correct 97 ms 8528 KB Output is correct
20 Correct 64 ms 8672 KB Output is correct
21 Correct 63 ms 8528 KB Output is correct
22 Correct 63 ms 8528 KB Output is correct
23 Correct 95 ms 8388 KB Output is correct
24 Correct 97 ms 8532 KB Output is correct