Submission #766527

# Submission time Handle Problem Language Result Execution time Memory
766527 2023-06-25T18:37:59 Z ihceker XORanges (eJOI19_xoranges) C++14
0 / 100
81 ms 65536 KB
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int arr[200005],s[2][800005];

void build(int node,int l,int r,int t){
	if(l==r){
		s[t][node]=arr[(t==0?l*2-1:l*2)];
		return;
	}
	int mid=(l+r)/2;
	build(node*2,l,mid,t);
	build(node*2+1,r,mid+1,t);
	s[t][node]=(s[t][node*2]^s[t][node*2+1]);
	return;
}

void update(int node,int l,int r,int x,int y,int t){
	if(l>x || r<x)return;
	if(l==r){
		s[t][node]=y;
		return;
	}
	int mid=(l+r)/2;
	update(node*2,l,mid,x,y,t);
	update(node*2+1,mid+1,r,x,y,t);
	s[t][node]=(s[t][node*2]^s[t][node*2+1]);
	return;
}

int query(int node,int l,int r,int x,int y,int t){
	if(l>y || r<x)return 0;
	if(l>=x && r<=y)return s[t][node];
	int mid=(l+r)/2;
	return (query(node*2,l,mid,x,y,t)^query(node*2+1,mid+1,r,x,y,t));
}

int32_t main(){
	int n,q;
	cin>>n>>q;
	for(int i=1;i<=n;i++)cin>>arr[i];
	int o=(n+1)/2,e=n/2;
	build(1,1,o,0);
	build(1,1,e,1);
	while(q--){
		int a,b,c;
		cin>>a>>b>>c;
		if(a==1){
			if(b%2){
				update(1,1,o,(b+1)/2,c,0);
			}
			else{
				update(1,1,e,b/2,c,1);
			}
		}
		else{
			if(b%2){
				cout<<query(1,1,o,(b+1)/2,(c+1)/2,0)<<endl;
			}
			else{
				cout<<query(1,1,e,b/2,c/2,1)<<endl;
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 81 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -