Submission #464337

# Submission time Handle Problem Language Result Execution time Memory
464337 2021-08-13T03:32:45 Z amunduzbaev XORanges (eJOI19_xoranges) C++14
0 / 100
202 ms 9392 KB
#include "bits/stdc++.h"
using namespace std;

const int n = 2e5;

struct ST{
	vector<int> tree;
	void init(){
		tree.resize(4 * n);
	}
	
	void sett(int i, int v, int lx = 0, int rx = n, int x = 1){
		//~ cout<<lx<<" "<<rx<<" "<<x<<" "<<(int)tree.size()<<endl;
		if(lx == rx) { tree[x] = v; return; }
		int m = (lx + rx)>>1;
		if(i <= m) sett(i, v, lx, m, x<<1);
		else sett(i, v, m+1, rx, x<<1|1);
		tree[x] = tree[x<<1] ^ tree[x<<1|1];
	} 
	
	int get(int l, int r, int lx = 0, int rx = n, int x = 1){
		if(lx > r || rx < l) return 0;
		if(lx >= l && rx <= r) return tree[x];
		int m = (lx + rx)>>1;
		return (get(l, r, lx, m, x<<1) ^ get(l, r, m+1, rx, x<<1|1));
	}
};

void solve(){
	int n, q; cin>>n>>q;
	vector<int> a(n);
	array<ST, 2> tree;
	tree[0].init(), tree[1].init();
	
	for(int i=0;i<n;i++){
		cin>>a[i];
		tree[i&1].sett(i, a[i]);
	}
	
	while(q--){
		int t; cin>>t;
		if(t == 1){
			int i, v; cin>>i>>v, i--;
			tree[i&1].sett(i, v);
		} else {
			int l, r; cin>>l>>r, l--, r--;
			cout<<tree[r&1].get(l, r)<<"\n";
		}
	}
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t = 1;
	//~ cin>>t;
	while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 202 ms 9392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6476 KB Output isn't correct
2 Halted 0 ms 0 KB -