Submission #437389

#TimeUsernameProblemLanguageResultExecution timeMemory
437389MinhQNgoXORanges (eJOI19_xoranges)C++17
18 / 100
39 ms460 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 505;

int a[N];
long long p[N];

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

    int n, q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        p[i] = p[i - 1] ^ a[i];
    }
    for (int _ = 0; _ < q; _++) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) a[x] = y;
        else {
            long long ans = 0;
            for (int l = 1; l <= y - x + 1; l++) {
                long long cur_xor = 0;
                for (int i = x; i + l - 1 <= y; i++) {
                    cur_xor ^= p[i + l - 1] ^ p[i - 1];
                }
                ans ^= cur_xor;
            }
            cout << ans << '\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...