Task: | Xor sum |
Sender: | joaquimballester |
Submission time: | 2024-09-23 16:31:45 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.52 s | details |
Code
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5; int main() { int n, q, arr[MAX_N + 1], prefix[MAX_N + 1], a, b; cin >> n >> q; for (int i = 1; i <= n; ++i) cin >> arr[i]; prefix[1] = arr[1]; for (int i = 2; i <= n; i++) prefix[i] = prefix[i - 1] ^ arr[i]; while (q--) { cin >> a >> b; cout << (prefix[a - 1] ^ prefix[b]) << 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 ... Truncated |