#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct node{
int s, e, m, val;
node *l, *r;
node(int _s, int _e){
s = _s, e = _e, m = (s + e) >> 1;
if(s != e)l = new node(s, m), r = new node(m+1, e);
val = 0;
}
void upd(int p, int v){
if(s == e)val = v;
else{
if(p <= m)l->upd(p, v);
else r->upd(p, v);
val = l->val ^ r->val;
}
}
int qry(int a, int b){
if(a == s && b == e)return val;
if(b <= m)return l->qry(a ,b);
if(a > m)return r->qry(a ,b);
return l->qry(a, m) ^ r->qry(m+1, b);
}
}*odd, *even;
int n, q, A[500005];
void solve(){
cin >> n >> q;
for(int i = 1; i <= n; i++)cin >> A[i];
odd = new node(1, n);
even = new node(1, n);
for(int i = 1; i <= n; i++){
if(i % 2)odd->upd(i, A[i]);
else even->upd(i, A[i]);
}
while(q--){
int a, b, c; cin >> a >> b >> c;
if(a == 1){
if(b%2)odd->upd(b, c);
else even->upd(b, c);
}
else{
if(c%2 != b%2)cout << 0 << '\n';
else cout << (b%2 ? odd->qry(b, c) : even->qry(b, c)) << '\n';
}
}
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int tc = 1;
//cin >> tc;
for(int tc1=1;tc1<=tc;tc1++){
// cout << "Case #" << tc1 << ": ";
solve();
}
}
Compilation message
xoranges.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
62 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
3 ms |
1884 KB |
Output is correct |
12 |
Correct |
3 ms |
1884 KB |
Output is correct |
13 |
Correct |
3 ms |
1884 KB |
Output is correct |
14 |
Correct |
3 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
225 ms |
58592 KB |
Output is correct |
2 |
Correct |
208 ms |
58760 KB |
Output is correct |
3 |
Correct |
202 ms |
58644 KB |
Output is correct |
4 |
Correct |
138 ms |
58356 KB |
Output is correct |
5 |
Correct |
139 ms |
58360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
3 ms |
1884 KB |
Output is correct |
12 |
Correct |
3 ms |
1884 KB |
Output is correct |
13 |
Correct |
3 ms |
1884 KB |
Output is correct |
14 |
Correct |
3 ms |
1884 KB |
Output is correct |
15 |
Correct |
225 ms |
58592 KB |
Output is correct |
16 |
Correct |
208 ms |
58760 KB |
Output is correct |
17 |
Correct |
202 ms |
58644 KB |
Output is correct |
18 |
Correct |
138 ms |
58356 KB |
Output is correct |
19 |
Correct |
139 ms |
58360 KB |
Output is correct |
20 |
Correct |
231 ms |
58344 KB |
Output is correct |
21 |
Correct |
207 ms |
58452 KB |
Output is correct |
22 |
Correct |
217 ms |
58444 KB |
Output is correct |
23 |
Correct |
146 ms |
58536 KB |
Output is correct |
24 |
Correct |
152 ms |
58348 KB |
Output is correct |