| Task: | Xor sum |
| Sender: | aalto26dm_033 |
| Submission time: | 2026-09-21 16:26:58 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.56 s | details |
Code
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long sum_xor(int a, int b, vector<long long>& tree) {
return (tree[b] ^ tree[a - 1]);
}
int main() {
int n, q;
cin >> n >> q;
vector<long long> indexed_tree(n+1, 0);
for (int i = 1; i <= n; i++) {
cin >> indexed_tree[i];
indexed_tree[i] = indexed_tree[i-1] ^ indexed_tree[i];
}
int a,b;
for(int i = 0; i < q; i++){
cin >> a >> b;
cout << sum_xor(a, b, indexed_tree) << endl;
}
}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 ... |
