#include <bits/stdc++.h>
using namespace std;
int n, q, i, a, b, quer;
int c[200005];
int seg[2][800020];
void Update(int start=1, int ende=n, int indx=1) {
if (start == ende) {
seg[a&1][indx] = b;
return;
}
int mid = (start+ende)/2;
if (a <= mid) Update(start, mid, 2*indx);
else Update(mid+1, ende, 2*indx+1);
seg[a&1][indx] = seg[a&1][2*indx]^seg[a&1][2*indx+1];
}
int Query(int from, int to, int start=1, int ende=n, int indx=1) {
if (from == start && to == ende) return seg[a&1][indx];
int mid = (start+ende)/2;
if (to <= mid) return Query(from, to, start, mid, 2*indx);
else if (from > mid) return Query(from, to, mid+1, ende, 2*indx+1);
else return Query(from, mid, start, mid, 2*indx)^Query(mid+1, to, mid+1, ende, 2*indx+1);
}
void Build(int start=1, int ende=n, int indx=1) {
if (start == ende) {
seg[start&1][indx] = c[start];
return;
}
int mid = (start+ende)/2;
Build(start, mid, 2*indx);
Build(mid+1, ende, 2*indx+1);
seg[0][indx] = seg[0][2*indx]^seg[0][2*indx+1];
seg[1][indx] = seg[1][2*indx]^seg[1][2*indx+1];
}
int main() {
scanf("%d%d", &n, &q);
for (i=1; i <= n; ++i) scanf("%d", &c[i]);
Build();
while (q--) {
scanf("%d%d%d", &quer, &a, &b);
if (quer == 1) Update();
else if ((a&1) != (b&1)) printf("0\n");
else printf("%d\n", Query(a, b));
}
return 0;
}
Compilation message
xoranges.cpp: In function 'int main()':
xoranges.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | scanf("%d%d", &n, &q);
| ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:43:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | for (i=1; i <= n; ++i) scanf("%d", &c[i]);
| ~~~~~^~~~~~~~~~~~~
xoranges.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | scanf("%d%d%d", &quer, &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
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 |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 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 |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
4 ms |
588 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
3 ms |
588 KB |
Output is correct |
14 |
Correct |
3 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
11204 KB |
Output is correct |
2 |
Correct |
149 ms |
11204 KB |
Output is correct |
3 |
Correct |
148 ms |
11248 KB |
Output is correct |
4 |
Correct |
132 ms |
10888 KB |
Output is correct |
5 |
Correct |
133 ms |
10924 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 |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
4 ms |
588 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
3 ms |
588 KB |
Output is correct |
14 |
Correct |
3 ms |
588 KB |
Output is correct |
15 |
Correct |
151 ms |
11204 KB |
Output is correct |
16 |
Correct |
149 ms |
11204 KB |
Output is correct |
17 |
Correct |
148 ms |
11248 KB |
Output is correct |
18 |
Correct |
132 ms |
10888 KB |
Output is correct |
19 |
Correct |
133 ms |
10924 KB |
Output is correct |
20 |
Correct |
150 ms |
10900 KB |
Output is correct |
21 |
Correct |
154 ms |
10948 KB |
Output is correct |
22 |
Correct |
153 ms |
10828 KB |
Output is correct |
23 |
Correct |
134 ms |
10780 KB |
Output is correct |
24 |
Correct |
133 ms |
10808 KB |
Output is correct |