Submission #1315167

#TimeUsernameProblemLanguageResultExecution timeMemory
1315167aaaaaaaaXORanges (eJOI19_xoranges)C++20
55 / 100
1093 ms2992 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
/*void brute(){
    int n;
    cin >> n;
    vector<int> ar(n + 5, 0);
    auto work = [&](int len) -> void {
        vector<int> update(n + 5, 0);
        for(int i = 1; i + len - 1 <= n; ++i){
            update[i] += 1, update[i + len] -= 1;
        }
        for(int i = 1; i <= n; ++i) update[i] += update[i - 1];
        for(int i = 1; i <= n; ++i) ar[i] += update[i];
    };
    for(int i = 1; i <= n; ++i){
        work(i);
    }
    for(int i = 1; i <= n; ++i) cout << (ar[i] & 1) << " ";
    cout << "\n";
}*/
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<int> ar(n + 1);
    for(int i = 1; i <= n; ++i){
        cin >> ar[i];
    }
    while(q--){
        int t, l, r;
        cin >> t >> l >> r;
        if(t == 1) ar[l] = r;
        else{
            int len = r - l + 1;
            if(len & 1 ^ 1) cout << "0\n";
            else{
                int ans = 0;
                for(int i = l; i <= r; i += 2){
                    ans ^= ar[i];
                }
                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...