Task: | Xor sum |
Sender: | Rasse |
Submission time: | 2024-09-23 16:29:25 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.52 s | details |
Code
// Online C++ compiler to run C++ program online #include <iostream> #include <vector> #include <climits> using namespace std; int main() { int n, q; cin >> n >> q; vector<int> xoris(n); int xori = 0; for (int i = 0; i < n; i++) { int val; cin >> val; xori ^= val; xoris[i] = xori; // cout << xoris[i] << " "; } for (int i = 0; i < q; i++) { int a, b; cin >> a >> b; if (a == 1) cout << xoris[b-1] << endl; else cout << (xoris[a-2] ^ xoris[b-1]) << 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: ACCEPTED
input |
---|
200000 200000 921726510 307633388 992247073 ... |
correct output |
---|
834756431 130379787 403037296 308618218 784778243 ... |
user output |
---|
834756431 130379787 403037296 308618218 784778243 ... Truncated |