#include<bits/stdc++.h>
using namespace std;
int arr[1000000], binary1[1000000], binary2[1000000];
int n, m;
void update1(int s, int k){
for(int i=s; i<=n; i+=i&-i)
binary1[i]=(binary1[i]^k);
}
int query1(int s){
int ans=0;
for(int i=s; i>=1; i-=i&-i)
ans=(ans^binary1[i]);
return ans;
}
void update2(int s, int k){
for(int i=s; i<=n; i+=i&-i)
binary2[i]=(binary2[i]^k);
}
int query2(int s){
int ans=0;
for(int i=s; i>=1; i-=i&-i)
ans=(ans^binary2[i]);
return ans;
}
int main(){
cin>>n>>m;
for(int i=1; i<=n; i++){
cin>>arr[i];
if(i%2==1)
update1(i, arr[i]);
else
update2(i, arr[i]);
}
for(int i=0; i<m; i++){
int hi;
cin>>hi;
if(hi==1){
int a, b;
cin>>a>>b;
if(a%2==1){
update1(a, (query1(a)^query1(a-1)));
update1(a, b);
}
else{
update2(a, (query2(a)^query2(a-1)));
update2(a, b);
}
}
else{
int a, b;
cin>>a>>b;
if((a-b+1)%2==0)
cout<<0<<'\n';
else if(a%2==1)
cout<<(query1(b)^query1(a-1))<<'\n';
else
cout<<(query2(b)^query2(a-1))<<'\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
19 ms |
512 KB |
Output is correct |
12 |
Correct |
18 ms |
512 KB |
Output is correct |
13 |
Correct |
21 ms |
512 KB |
Output is correct |
14 |
Correct |
21 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
960 ms |
8936 KB |
Output is correct |
2 |
Correct |
924 ms |
8696 KB |
Output is correct |
3 |
Correct |
929 ms |
8824 KB |
Output is correct |
4 |
Correct |
895 ms |
8696 KB |
Output is correct |
5 |
Correct |
903 ms |
8448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
19 ms |
512 KB |
Output is correct |
12 |
Correct |
18 ms |
512 KB |
Output is correct |
13 |
Correct |
21 ms |
512 KB |
Output is correct |
14 |
Correct |
21 ms |
512 KB |
Output is correct |
15 |
Correct |
960 ms |
8936 KB |
Output is correct |
16 |
Correct |
924 ms |
8696 KB |
Output is correct |
17 |
Correct |
929 ms |
8824 KB |
Output is correct |
18 |
Correct |
895 ms |
8696 KB |
Output is correct |
19 |
Correct |
903 ms |
8448 KB |
Output is correct |
20 |
Correct |
743 ms |
8660 KB |
Output is correct |
21 |
Correct |
737 ms |
8660 KB |
Output is correct |
22 |
Correct |
732 ms |
8768 KB |
Output is correct |
23 |
Correct |
893 ms |
8440 KB |
Output is correct |
24 |
Correct |
931 ms |
8688 KB |
Output is correct |