CSES - Aalto Competitive Programming 2024 - wk4 - Mon - Results
Submission details
Task:Xor sum
Sender:odanobunaga8199
Submission time:2024-09-23 17:19:56 +0300
Language:C++ (C++20)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.09 sdetails

Code

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<long long> arr(n);
    for(auto &x: arr) cin >> x;
    vector<long long> prefix(n+1, 0);
    for(int i=1; i<=n; ++i){
        prefix[i] = prefix[i-1] ^ arr[i-1];
    }
    while(q--){
        int a, b;
        cin >> a >> b;
        cout << (prefix[b] ^ prefix[a-1]) << "\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