| Task: | Xor sum |
| Sender: | aalto26dm_030 |
| Submission time: | 2026-09-21 17:08:07 +0300 |
| Language: | C++ (C++23) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.00 s | details |
| #2 | RUNTIME ERROR | 0.01 s | details |
Code
#include <iostream>
#include <vector>
#include <string>
int main(int argc, char** argv) {
long long n, q;
std::cin >> n >> q;
std::vector<long long> numbers(n, 0);
std::vector<long long> xor_until_n(n+1, 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(-1);
} else if (i > 2) {
xor_until_n.at(i) = xor_until_n.at(i-1) ^ 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 long a, b;
std::cin >> a >> b;
int r = xor_until_n.at(b) - xor_until_n.at(a);
result = result + std::to_string(r) + '\n';
}
std::cout << result << std::endl;
return 0;
}
Test details
Test 1
Verdict: RUNTIME ERROR
| 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 |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 18446744073709551615) >= this->size() (which is 8)
Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 200000 200000 921726510 307633388 992247073 ... |
| correct output |
|---|
| 834756431 130379787 403037296 308618218 784778243 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 18446744073709551615) >= this->size() (which is 200000)
