| Task: | Xor sum |
| Sender: | aalto26dm_018 |
| Submission time: | 2026-09-21 16:40:45 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.09 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size() // signed size: avoids the unsigned .size() wrap bug
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
#ifdef LOCAL // compile with -DLOCAL to enable, silent on the judge
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "] = ", dbg_out(__VA_ARGS__)
template<class T> void dbg_out(T x) { cerr << x << '\n'; }
template<class T, class... R> void dbg_out(T x, R... r) { cerr << x << ", "; dbg_out(r...); }
#else
#define dbg(...)
#endif
int main() {
cin.tie(0)->sync_with_stdio(0); // never mix with scanf/printf after this
// int n; cin >> n;
int n,q; cin >> n >> q;
vi a(n); for (auto &x : a) cin >> x;
vi cum(n+1);
int current = 0;
for (int i = 0; i < n+1; i++)
{
cum[i] = current;
// cout << current << "\n";
current = current ^ a[i];
}
int c,b;
for (int i = 0; i < q; i++)
{
cin >> c >> b;
int out = cum[c-1] ^ cum[b+1-1];
// int out = (int) 2 ^ 4 ^ 5 ;
// cout << cum[c-1] << " " << cum[b+1-1] << " ";
cout << out << "\n";
}
// cout << ;
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 ... |
