#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
const int N = 2e5+7;
int a[N];
int st1[4*N];
int st2[4*N];
void Build(int node, int l, int r){
if(l>r)return;
if(l == r){
if(l&1){
st2[node] = a[l];
}
else{
st1[node] = a[l];
}
return;
}
int mid = (l+r)/2;
Build(2*node+1, l, mid);
Build(2*node+2, mid+1, r);
st1[node] = st1[2*node+1] ^ st1[2*node+2];
st2[node] = st2[2*node+1] ^ st2[2*node+2];
}
void Update(int node, int l, int r, int ind, int val){
if(l>r || l>ind || r<ind) return;
if(l == r){
if(l&1){
st2[node] = val;
}
else st1[node] = val;
return;
}
else{
int mid = (l+r)/2;
Update(2*node+1, l, mid, ind, val);
Update(2*node+2, mid+1, r, ind, val);
}
st2[node] = st2[2*node+1] ^ st2[2*node+2];
st1[node] = st1[2*node+1] ^ st1[2*node+2];
}
int qry1(int node, int l, int r, int L, int R){
if(l>R || r<L || l>r){
return 0;
}
else if(l>=L && r<=R){
return st1[node];
}
else{
int mid = (l+r)/2;
return qry1(2*node+1, l, mid, L, R)^qry1(2*node+2, mid+1, r, L, R);
}
}
int32_t main(){
int n, q;
cin >> n >> q;
for(int i = 0; i < n; i++){
cin >> a[i];
}
Build(0, 0, n-1);
while(q--){
int t;
cin >> t;
if(t==1){
int a, b;
cin >> a >> b;
a--;
Update(0, 0, n-1, a, b);
}
else{
int l, r;
cin >> l >> r;
r--; l--;
int len=r-l+1;
if(len&1){
cout << qry1(0, 0, n-1, l, r) << '\n';
}
else{
cout << 0 << '\n';
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
463 ms |
16044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |