#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 2e5+10;
struct BIT{
int bit[mxn];
BIT(){}
void modify(int p,int v){
for(;p<mxn;p+=p&-p)bit[p] ^= v;
return;
}
int getval(int s,int e){
int re = 0;
for(;e>0;e-= e&-e)re ^= bit[e];
s--;
for(;s>0;s-= s&-s)re ^= bit[s];
return re;
}
};
BIT od,ev;
int N,Q;
int arr[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>Q;
for(int i = 1;i<=N;i++){
cin>>arr[i];
if(i&1)od.modify(i,arr[i]);
else ev.modify(i,arr[i]);
}
while(Q--){
int t,a,b;
cin>>t>>a>>b;
if(t == 1){
if(a&1){
od.modify(a,arr[a]);
arr[a] = b;
od.modify(a,arr[a]);
}
else{
ev.modify(a,arr[a]);
arr[a] = b;
ev.modify(a,arr[a]);
}
}
else{
if((b-a+1)%2 == 0)cout<<"0\n";
else if(a&1)cout<<od.getval(a,b)<<'\n';
else cout<<ev.getval(a,b)<<'\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2512 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2512 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
3 ms |
2632 KB |
Output is correct |
12 |
Correct |
2 ms |
2648 KB |
Output is correct |
13 |
Correct |
4 ms |
2648 KB |
Output is correct |
14 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
3840 KB |
Output is correct |
2 |
Correct |
66 ms |
3804 KB |
Output is correct |
3 |
Correct |
66 ms |
3744 KB |
Output is correct |
4 |
Correct |
71 ms |
3924 KB |
Output is correct |
5 |
Correct |
61 ms |
3920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2512 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
3 ms |
2632 KB |
Output is correct |
12 |
Correct |
2 ms |
2648 KB |
Output is correct |
13 |
Correct |
4 ms |
2648 KB |
Output is correct |
14 |
Correct |
2 ms |
2652 KB |
Output is correct |
15 |
Correct |
68 ms |
3840 KB |
Output is correct |
16 |
Correct |
66 ms |
3804 KB |
Output is correct |
17 |
Correct |
66 ms |
3744 KB |
Output is correct |
18 |
Correct |
71 ms |
3924 KB |
Output is correct |
19 |
Correct |
61 ms |
3920 KB |
Output is correct |
20 |
Correct |
64 ms |
8528 KB |
Output is correct |
21 |
Correct |
67 ms |
8460 KB |
Output is correct |
22 |
Correct |
70 ms |
8572 KB |
Output is correct |
23 |
Correct |
70 ms |
8272 KB |
Output is correct |
24 |
Correct |
68 ms |
8276 KB |
Output is correct |