#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()
vector<int> arr;
vector<vector<int>> st;
int build(int n, int s, int e, int t){
if(s==e) return st[t][n]=(s%2==t ? arr[s]:0);
int mid=(s+e)/2;
return st[t][n]=build(n*2, s, mid, t)^build(n*2+1, mid+1, e, t);
}
int query(int n, int s, int e, int l, int r, int t){
if(s>=l && e<=r) return st[t][n];
if(s>r || e<l) return 0;
int mid=(s+e)/2;
return query(n*2, s, mid, l, r, t)^query(n*2+1, mid+1, e, l, r, t);
}
int update(int n, int s, int e, int i, int v, int t){
if(s>i || e<i) return st[t][n];
if(s==e) return st[t][n]=v;
int mid=(s+e)/2;
return st[t][n]=update(n*2, s, mid, i, v, t)^update(n*2+1, mid+1, e, i, v, t);
}
int main(){
int n, q;
cin>>n>>q;
arr.resize(n+1); st.resize(2, vector<int>(6*n));
for(int i=1; i<=n; i++) cin>>arr[i];
build(1, 1, n, 0); build(1, 1, n, 1);
while(q--){
int t, a, b;
cin>>t>>a>>b;
if(t==1) update(1, 1, n, a, b, a%2);
else if((b-a)%2) cout<<0<<endl;
else cout<<query(1, 1, n, a, b, a%2)<<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 |
2 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 |
2 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 |
2 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 |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
13 ms |
668 KB |
Output is correct |
12 |
Correct |
13 ms |
676 KB |
Output is correct |
13 |
Correct |
15 ms |
792 KB |
Output is correct |
14 |
Correct |
15 ms |
672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
707 ms |
15052 KB |
Output is correct |
2 |
Correct |
683 ms |
15052 KB |
Output is correct |
3 |
Correct |
667 ms |
15052 KB |
Output is correct |
4 |
Correct |
638 ms |
15052 KB |
Output is correct |
5 |
Correct |
643 ms |
15052 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 |
2 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 |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
13 ms |
668 KB |
Output is correct |
12 |
Correct |
13 ms |
676 KB |
Output is correct |
13 |
Correct |
15 ms |
792 KB |
Output is correct |
14 |
Correct |
15 ms |
672 KB |
Output is correct |
15 |
Correct |
707 ms |
15052 KB |
Output is correct |
16 |
Correct |
683 ms |
15052 KB |
Output is correct |
17 |
Correct |
667 ms |
15052 KB |
Output is correct |
18 |
Correct |
638 ms |
15052 KB |
Output is correct |
19 |
Correct |
643 ms |
15052 KB |
Output is correct |
20 |
Correct |
541 ms |
15124 KB |
Output is correct |
21 |
Correct |
532 ms |
15052 KB |
Output is correct |
22 |
Correct |
545 ms |
15052 KB |
Output is correct |
23 |
Correct |
627 ms |
15052 KB |
Output is correct |
24 |
Correct |
642 ms |
15052 KB |
Output is correct |