Submission #1128938

#TimeUsernameProblemLanguageResultExecution timeMemory
1128938MathiasXORanges (eJOI19_xoranges)C++20
100 / 100
85 ms4816 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define fi first
#define sc second
#define vi vector<int>
#define pii pair<int,int>
#define vpi vector<pair<int,int> >
#define mp make_pair 
const ll MOD1 = 1e9+7;
const ll MOD2 = 998244353;
const ll MOD3 = 1e9+93;
const ll MOD4 = 1e9+97;
const ll p1 = 1e9+87;
const ll p2 = 1e9+9;
const int INF = 1e9+7;
const int BASE = 1<<18;
const int LOG = 20;
const int ALF = 27;
const int MAXN = 1e6+7;
const int MAXNN = 1e3+7;
int tree[2][2*BASE];
void put(int k,int x,int y){
	x+=BASE, tree[k][x]=y, x/=2;
	while(x>0) tree[k][x]=tree[k][2*x]^tree[k][2*x+1], x/=2;
}
int query(int k,int x,int y){
	x+=BASE-1, y+=BASE+1; int r=0;
	while(x/2!=y/2){
		if(x%2==0) r^=tree[k][x+1];
		if(y%2==1) r^=tree[k][y-1];
		x/=2, y/=2;
	}
	return r;
}
void solve(){
	int n,q,x,y,a;
	cin>>n>>q;
	for(int i=1;i<=n;i++) cin>>x, put(i%2,i,x);
	while(q--){
		cin>>a>>x>>y;
		if(a==1) put(x%2,x,y);
		else{
			if(x%2!=y%2) cout<<0<<'\n';
			else cout<<query(x%2,x,y)<<'\n';
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int tt=1;
	while(tt--) solve();	
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...