제출 #242110

#제출 시각아이디문제언어결과실행 시간메모리
242110valerikkXORanges (eJOI19_xoranges)C++17
100 / 100
123 ms11128 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long 

const int N = 2e5 + 7;

int t[2][N];

void upd(int ind, int val){
    for(int i = ind + 1; i < N; i += i & -i){
        t[ind & 1][i] ^= val;
    }
}

int get(int par, int ind){
    int res = 0;
    for(; ind > 0; ind -= ind & -ind){
        res ^= t[par][ind];
    }
    return res;
}

int get(int par, int l, int r){
    return get(par, r) ^ get(par, l);
}

int n, q, a[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        upd(i, a[i]);
    }
    while(q--){
        int type;
        cin >> type;
        if(type == 1){
            int ind, val;
            cin >> ind >> val;
            ind--;
            upd(ind, a[ind] ^ val);
            a[ind] = val;
        } 
        if(type == 2){
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int ans = 0;
            if((l & 1) & (r & 1)){
                ans ^= get(1, l, r + 1);
            }
            if(((l & 1) ^ 1) & ((r & 1) ^ 1)){
                ans ^= get(0, l, r + 1);
            }
            cout << ans << '\n';
        }
    }
    return 0;
}
#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...