This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/// tree bends in youth
/// 24.01.2024
/// success is doing same thing in every single day!!!
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
const ll N = 5e3 + 5;
const ll maxn =1e6 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll LG = 18;
int a[N];
pair<int,int> t[4 * N];
void build(int v,int l,int r){
if(l == r){
t[v].F= a[((l - 1) * 2) + 1];
t[v].S = a[(l * 2)];
return;
}
int mid = (l + r) / 2;
build(v+v,l,mid);
build(v+v+1,mid+1,r);
t[v].F =(t[v+v].F ^ t[v+v+1].F);
t[v].S =(t[v+v].S ^ t[v+v+1].S);
}
void upd(int v,int l,int r,int pos,int val,bool s){
if(l == r){
if(s)t[v].F = val;
else t[v].S = val;
return;
}
int mid = (l + r ) / 2;
if(pos <= mid)upd(v+v,l,mid,pos,val,s);
else upd(v+v+1,mid+1,r,pos,val,s);
t[v].F =(t[v+v].F ^ t[v+v+1].F);
t[v].S =(t[v+v].S ^ t[v+v+1].S);
}
int get(int v,int l,int r,int ql,int qr,bool s){
if(ql <= l && r <= qr){
if(s)return t[v].F;
else return t[v].S;
}
if(qr < l || r < ql)return 0;
int mid = (l + r) / 2;
return ((get(v+v,l,mid,ql,qr,s)) ^ (get(v+v+1,mid+1,r,ql,qr,s)));
}
void solve(){
int n,q;cin >> n >> q;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
build(1,1,((n + 1) / 2));
while(q--){
int tp;cin >> tp;
if(tp == 1){
int i,j;cin >> i >> j;
upd(1,1,((n + 1) / 2),((i + 1) / 2),j,(i % 2));
}
else{
int l,r;cin >> l >> r;
if((r - l + 1) % 2 == 0){
cout << "0\n";
}
else{
bool ok = (l % 2);
l = (l + 1) / 2;
r= (r + 1) / 2;
int x = get(1,1,((n + 1) / 2),l,r,ok);
cout <<x << '\n';
}
}
}
}
main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("haybales.in","r",stdin);
// freopen("haybales.out","w",stdout);
ll abd= 1;
// cin >> abd;
for(ll i = 1;i <= abd;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
Compilation message (stderr)
xoranges.cpp:78:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
78 | main (){
| ^~~~
# | 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... |