Submission #582758

# Submission time Handle Problem Language Result Execution time Memory
582758 2022-06-24T11:33:52 Z pakapu XORanges (eJOI19_xoranges) C++14
0 / 100
55 ms 65536 KB
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <bitset>
#include <math.h>

using namespace std;

const int MOD = 1e9 + 7;

vector<int> a;
vector<int> sg;

void build(int node, int l, int r) {
    if(l == r) {
        sg[node] = a[l];
        return;
    }

    int mid = (l + r) / 2;
    build(node * 2, l, mid);
    build(node * 2 + 1, mid + 1, r);

    sg[node] = sg[node * 2] ^ sg[node * 2 + 1];
}

long long query(int node, int l, int r, int a, int b) {
    if(l == a && b == r) {
        return sg[node];
    }

    int mid = (l + r) / 2;
    return query(node * 2, l, mid, a, b) ^ query(node * 2 + 1, mid + 1, r, a, b);
}

void update(int node, int l, int r, int pos, int val) {
    if(l == r) {
        sg[node] ^= val;
    }
    else {
        int mid = (l + r) / 2;
        if(pos <= mid) {
            update(node * 2, l, mid, pos, val);
        }
        else {
            update(node * 2 + 1, mid + 1, r, pos, val);
        }
        sg[node] = sg[node * 2] ^ sg[node * 2 + 1];
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, tt;
    cin >> n >> tt;

    a = vector<int>(n + 1);
    sg = vector<int>(4 * n);

    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    build(1, 1, n);

    while(tt--) {
        int t, a, b;
        cin >> t >> a >> b;

        switch(t) {
            case 1:
                update(1, 1, n, a, b);
                break;
            case 2:
                cout << query(1, 1, n, a, b) << '\n';
                break;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -