using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
vector<int> odd;
vector<int> eve;
vector<int> val;
int n, q;
void fun() {
int xo = 0;
for (int i = 0; i < n; i += 2) {
xo = xo ^ val[i];
eve.push_back(xo);
}
xo = 0;
for (int i = 1; i < n; i += 2) {
xo = xo ^ val[i];
odd.push_back(xo);
}
}
int main()
{
cin >> n;
cin >> q;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
val.push_back(x);
}
fun();
for (int i = 0; i < q; i++) {
int a, b, c;
cin >> a;
cin >> b;
cin >> c;
if (a == 1) {
val[b - 1] = c;
fun();
}
else {
if ((b - c) % 2 == 0) {
cout << 0 << endl;
}
else {
if ((b - 1) % 2 == 0) {
int x = (odd[(b - 2) / 2])^(odd[(c-2) / 2]);
cout << x << endl;
}
else {
int x = eve[(b - 2) / 2] ^ eve[(c-2) / 2];
cout << x << endl;
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
590 ms |
3612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |