이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |