| Task: | Xor sum |
| Sender: | duongha |
| Submission time: | 2025-09-22 16:43:10 +0300 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.35 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
const int MAXN =2e5 + 1;
long long n, q, u, v;
long long f[MAXN], a[MAXN];
void solve() {
cin >> n >> q;
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
f[0] = 0;
for(int i = 1; i <= n; i++) {
f[i] = f[i - 1] ^ a[i];
//cout << f[i] << ' ';
}
for(int i = 1; i <= q; i++) {
cin >> u >> v;
long long temp = f[u - 1] ^ f[v];
cout << temp << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}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 |
