#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
int N, Q;
cin >> N >> Q;
int ts = 2;
while(ts/2<N/2+1)ts*=2;
vector<int> a1(ts);
vector<int> a(ts);
for(int i = 0; i < N; i++){
if(i%2) cin >> a1[i/2+ts/2];
else cin >> a[i/2+ts/2];
}
for(int i = ts/2-1; i > 0; i--) a[i]=a[i*2]^a[i*2+1];
for(int i = ts/2-1; i > 0; i--) a1[i]=a1[i*2]^a1[i*2+1];
for(int i = 0; i < Q; i++){
int optype;
cin >> optype;
if(optype == 1){
int j, t;
cin >> j >> t;
j--;
j/=2;
j+=ts/2;
if(j%2){
a1[j]=t;
j/=2;
while(j!=0){
a1[j]=a1[j*2]^a1[j*2+1];
j/=2;
}
}else{
a[j]=t;
j/=2;
while(j!=0){
a[j]=a[j*2]^a[j*2+1];
j/=2;
}
}
}else{
int l, r;
cin >> l >> r;
if((l-r)%2==1) {
cout << 0;
continue;
}
l--; r--;
l/=2; r/=2;
l+=ts/2; r+=ts/2;
if(!(l%2)){
if(l==r) {
cout <<a[l] << '\n';
continue;
}
int fin = a[l]^a[r];
while(l/2!=r/2){
if(!(l%2)) fin^=a[l+1];
if(r%2) fin^=a[r-1];
l/=2; r/=2;
}
cout << fin << '\n';
}else{
if(l==r){
cout << a1[l] << '\n';
continue;
}
int fin = a1[l]^a1[r];
while(l/2!=r/2){
if(!(l%2)) fin^=a1[l+1];
if(r%2) fin^=a1[r-1];
l/=2; r/=2;
}
cout << fin << '\n';
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
633 ms |
5044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |