This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
int n,q;
cin>>n>>q;
vector<int>a(n+1),pre(n+1,0),pre2(n+1,0);
for(int i=1;i<=n;i++){
cin>>a[i];
if(i&1){
pre[i]=(pre[i-1]^a[i]);
pre2[i]=pre2[i-1];
}
else{
pre2[i]=(pre2[i-1]^a[i]);
pre[i]=pre[i-1];
}
}
while(q--){
int ind,l,r;
cin>>ind>>l>>r;
if(ind==2){
if(l&1){
cout<<(pre[r]^pre[l-1])<<"\n";
}
else{
cout<<(pre2[r]^pre2[l-1])<<"\n";
}
}
else{
a[l]=r;
if(l&1){
for(int i=l;i<=n;i++){
if(i&1){
pre[i]=(pre[i-1]^a[i]);
}
else{
pre[i]=pre[i-1];
}
}
}
else{
for(int i=l;i<=n;i++){
if(i&1){
pre2[i]=pre2[i-1];
}
else{
pre2[i]=(pre2[i-1]^a[i]);
}
}
}
}
}
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... |