Submission #1180755

#TimeUsernameProblemLanguageResultExecution timeMemory
1180755petezaXORanges (eJOI19_xoranges)C++20
100 / 100
49 ms3144 KiB
#include <bits/stdc++.h>
using namespace std;

int n, q, x, y, z;
int fwk[2][100005];
int ch[200005];

void upd(int bruh[100005], int x, int val) {
    for(;x<=100000;x+=x&-x)
        bruh[x] ^= val;
}

int qr(int bruh[100005], int x) {
    int sum = 0;
    for(;x;x-=x&-x)
        sum ^= bruh[x];
    return sum;
}

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    cin >> n >> q;
    for(int i=1;i<=n;i++) {
        cin >> x; ch[i] = x;
        upd(fwk[i&1], (i+1) >> 1, x);
    }
    while(q--) {
        cin >> x >> y >> z;
        if(x == 1) {
            upd(fwk[y&1], (y+1) >> 1, ch[y]);
            ch[y] = z;
            upd(fwk[y&1], (y+1) >> 1, ch[y]);
        } else {
            if((y^z)&1) {cout << "0\n";}
            else {
                cout << (qr(fwk[z&1], (z+1)>>1) ^ (qr(fwk[y&1], ((y+1) >> 1) - 1))) << '\n';
            }
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...