Submission #464339

# Submission time Handle Problem Language Result Execution time Memory
464339 2021-08-13T03:38:10 Z amunduzbaev XORanges (eJOI19_xoranges) C++14
100 / 100
194 ms 9044 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--;
			if((r - l + 1) & 1) cout<<tree[l&1].get(l, r)<<"\n";
			else cout<<0<<"\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 Correct 4 ms 6476 KB Output is correct
2 Correct 5 ms 6476 KB Output is correct
3 Correct 4 ms 6476 KB Output is correct
4 Correct 3 ms 6476 KB Output is correct
5 Correct 4 ms 6476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6476 KB Output is correct
2 Correct 4 ms 6604 KB Output is correct
3 Correct 5 ms 6604 KB Output is correct
4 Correct 4 ms 6604 KB Output is correct
5 Correct 3 ms 6596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6476 KB Output is correct
2 Correct 5 ms 6476 KB Output is correct
3 Correct 4 ms 6476 KB Output is correct
4 Correct 3 ms 6476 KB Output is correct
5 Correct 4 ms 6476 KB Output is correct
6 Correct 4 ms 6476 KB Output is correct
7 Correct 4 ms 6604 KB Output is correct
8 Correct 5 ms 6604 KB Output is correct
9 Correct 4 ms 6604 KB Output is correct
10 Correct 3 ms 6596 KB Output is correct
11 Correct 9 ms 6732 KB Output is correct
12 Correct 8 ms 6732 KB Output is correct
13 Correct 7 ms 6732 KB Output is correct
14 Correct 7 ms 6732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 171 ms 8988 KB Output is correct
2 Correct 165 ms 8980 KB Output is correct
3 Correct 185 ms 8952 KB Output is correct
4 Correct 147 ms 9020 KB Output is correct
5 Correct 147 ms 9044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6476 KB Output is correct
2 Correct 5 ms 6476 KB Output is correct
3 Correct 4 ms 6476 KB Output is correct
4 Correct 3 ms 6476 KB Output is correct
5 Correct 4 ms 6476 KB Output is correct
6 Correct 4 ms 6476 KB Output is correct
7 Correct 4 ms 6604 KB Output is correct
8 Correct 5 ms 6604 KB Output is correct
9 Correct 4 ms 6604 KB Output is correct
10 Correct 3 ms 6596 KB Output is correct
11 Correct 9 ms 6732 KB Output is correct
12 Correct 8 ms 6732 KB Output is correct
13 Correct 7 ms 6732 KB Output is correct
14 Correct 7 ms 6732 KB Output is correct
15 Correct 171 ms 8988 KB Output is correct
16 Correct 165 ms 8980 KB Output is correct
17 Correct 185 ms 8952 KB Output is correct
18 Correct 147 ms 9020 KB Output is correct
19 Correct 147 ms 9044 KB Output is correct
20 Correct 162 ms 8476 KB Output is correct
21 Correct 194 ms 8372 KB Output is correct
22 Correct 164 ms 8424 KB Output is correct
23 Correct 149 ms 8936 KB Output is correct
24 Correct 155 ms 8920 KB Output is correct