Submission details
Task:Xor sum
Sender:saimou
Submission time:2025-09-22 16:52:22 +0300
Language:C++ (C++20)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.25 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;

    vector<int> arr(n + 1);
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        arr[i] = x;
    }
    vector<int> pre(n + 1);
    pre[1] = arr[1];
    for (int i = 2; i <= n; i++) {
        pre[i] = pre[i - 1] ^ arr[i];
    }

    vector<int> res;
    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;
        res.push_back(pre[a - 1] ^ pre[b]);
    }

    for (auto k : res) {
        cout << k << "\n";
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
8 36
7 6 4 6 2 9 4 8
1 1
1 2
1 3
...

correct output
7
1
5
3
1
...

user output
7
1
5
3
1
...

Test 2

Verdict: ACCEPTED

input
200000 200000
921726510 307633388 992247073 ...

correct output
834756431
130379787
403037296
308618218
784778243
...

user output
834756431
130379787
403037296
308618218
784778243
...
Truncated