#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
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[i] = xo;
}
xo = 0;
for (int i = 1; i < n; i += 2) {
xo = xo ^ val[i];
odd[i] = xo;
}
}
int main()
{
cin >> n;
cin >> q;
odd.resize(n);
eve.resize(n);
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-1) % 2 == 0) {
cout << 0 << endl;
}
else {
if (b == 1) {
cout << eve[(c - 1) ] << endl;
}
else if
((b - 1) % 2 == 0) {
int x = (eve[(b - 3)]) ^ (eve[(c - 1)]);
cout << x << endl;
}
else if (b == 2) {
cout << odd[(c - 1)] << endl;
} else{
int x = odd[(b - 3)] ^ odd[(c-1)];
cout << x << endl;
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
3 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
22 ms |
460 KB |
Output is correct |
12 |
Correct |
20 ms |
452 KB |
Output is correct |
13 |
Correct |
15 ms |
496 KB |
Output is correct |
14 |
Correct |
16 ms |
520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
623 ms |
3904 KB |
Output is correct |
2 |
Correct |
606 ms |
3948 KB |
Output is correct |
3 |
Correct |
616 ms |
5520 KB |
Output is correct |
4 |
Correct |
617 ms |
5552 KB |
Output is correct |
5 |
Correct |
580 ms |
5564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
22 ms |
460 KB |
Output is correct |
12 |
Correct |
20 ms |
452 KB |
Output is correct |
13 |
Correct |
15 ms |
496 KB |
Output is correct |
14 |
Correct |
16 ms |
520 KB |
Output is correct |
15 |
Correct |
623 ms |
3904 KB |
Output is correct |
16 |
Correct |
606 ms |
3948 KB |
Output is correct |
17 |
Correct |
616 ms |
5520 KB |
Output is correct |
18 |
Correct |
617 ms |
5552 KB |
Output is correct |
19 |
Correct |
580 ms |
5564 KB |
Output is correct |
20 |
Execution timed out |
1082 ms |
3452 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |