#include <bits/stdc++.h>
using namespace std;
vector<long long> st;
vector<long long> st2;
void build(vector<long long> a, long long v, long long tl, long long tr){
if(tl==tr) st[v]=a[tl];
else{
long long tm=(tl+tr)/2;
build(a,v*2,tl,tm);
build(a,v*2+1,tm+1,tr);
st[v]=st[v*2]^st[v*2+1];
}
}
long long XUM(long long v, long long tl, long long tr, long long l, long long r){
if(l>r) return 0;
if(l==tl and r==tr) return st[v];
long long tm=(tl+tr)/2;
return XUM(v*2,tl,tm,l,min(r,tm))^XUM(v*2+1,tm+1,tr,max(l,tm+1),r);
}
void update(long long v, long long tl, long long tr, long long pos, long long new_val){
if(tl==tr){
st[v]=new_val;
}
else{
long long tm=(tl+tr)/2;
if(pos<=tm) update(v*2,tl,tm,pos,new_val);
else update(v*2+1,tm+1,tr,pos,new_val);
st[v]=st[v*2]^st[v*2+1];
}
}
void build2(vector<long long> a, long long v, long long tl, long long tr){
if(tl==tr) st2[v]=a[tl];
else{
long long tm=(tl+tr)/2;
build2(a,v*2,tl,tm);
build2(a,v*2+1,tm+1,tr);
st2[v]=st2[v*2]^st2[v*2+1];
}
}
long long XUM2(long long v, long long tl, long long tr, long long l, long long r){
if(l>r) return 0;
if(l==tl and r==tr) return st2[v];
long long tm=(tl+tr)/2;
return XUM2(v*2,tl,tm,l,min(r,tm))^XUM2(v*2+1,tm+1,tr,max(l,tm+1),r);
}
void update2(long long v, long long tl, long long tr, long long pos, long long new_val){
if(tl==tr){
st2[v]=new_val;
}
else{
long long tm=(tl+tr)/2;
if(pos<=tm) update2(v*2,tl,tm,pos,new_val);
else update2(v*2+1,tm+1,tr,pos,new_val);
st2[v]=st2[v*2]^st2[v*2+1];
}
}
int main(){
long long n,q;
cin >> n >> q;
vector<long long> a;
vector<long long> a2;
st.resize(4*((n+1)/2));
st2.resize(4*(n/2));
for(long long i=0;i<n;i++){
long long x;
cin >> x;
if(i%2==0)a.push_back(x);
else a2.push_back(x);
}
build(a,1,0,((n+1)/2)-1);
build2(a2,1,0,n/2-1);
while(q--){
long long action;
cin >> action;
if(action==1){
long long pos,ch;
cin >> pos >> ch;
if(pos%2!=0) update(1,0,(n+1)/2-1,pos/2,ch);
else update2(1,0,n/2-1,pos/2-1,ch);
}
else{
long long l,u;
cin >> l >> u;
if((u-l)%2==1) cout << 0<<"\n";
else{
if(l%2==1){
long long xum=XUM(1,0,((n+1)/2)-1,l/2,u/2);
cout << xum<<"\n";
}
else{
long long xum=XUM2(1,0,(n/2)-1,l/2-1,u/2-1);
cout << xum<<"\n";
}
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
308 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
308 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
11 |
Correct |
15 ms |
888 KB |
Output is correct |
12 |
Correct |
19 ms |
888 KB |
Output is correct |
13 |
Correct |
20 ms |
868 KB |
Output is correct |
14 |
Correct |
16 ms |
864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1064 ms |
22904 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
308 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
11 |
Correct |
15 ms |
888 KB |
Output is correct |
12 |
Correct |
19 ms |
888 KB |
Output is correct |
13 |
Correct |
20 ms |
868 KB |
Output is correct |
14 |
Correct |
16 ms |
864 KB |
Output is correct |
15 |
Execution timed out |
1064 ms |
22904 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |