| Task: | Xor sum |
| Sender: | aalto26dm_030 |
| Submission time: | 2026-09-21 17:25:39 +0300 |
| Language: | C++ (C++23) |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | TIME LIMIT EXCEEDED | -- | details |
Code
#include <iostream>
#include <vector>
#include <string>
int main(int argc, char** argv) {
std::cin.tie(0)->sync_with_stdio(0);
long n, q;
std::cin >> n >> q;
std::vector<long> numbers(n, 0);
std::vector<long> xor_until_n(n+2, 0);
for (int i=0; i<n; i++) {
int m;
std::cin >> m;
numbers.at(i) = m;
if (i == 2) {
xor_until_n.at(i) = numbers.at(i-2) ^ numbers.at(i-1);
} else if (i > 2) {
xor_until_n.at(i) = xor_until_n.at(i-1) ^ numbers.at(i-1);
} else if (i == 1) {
xor_until_n.at(i) = numbers.at(i-1);
}
}
xor_until_n.at(n) = xor_until_n.at(n-1) ^ numbers.at(n-1);
std::string result;
for (int i=0; i<q; i++) {
long a, b;
std::cin >> a >> b;
a--;
b--;
long r = xor_until_n.at(b+1) ^ xor_until_n.at(a);
result = result + std::to_string(r) + '\n';
}
std::cout << result << std::endl;
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: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 200000 921726510 307633388 992247073 ... |
| correct output |
|---|
| 834756431 130379787 403037296 308618218 784778243 ... |
| user output |
|---|
| (empty) |
