Submission #446791

# Submission time Handle Problem Language Result Execution time Memory
446791 2021-07-23T09:18:03 Z fuad27 XORanges (eJOI19_xoranges) C++14
38 / 100
600 ms 3096 KB
#include<bits/stdc++.h>
using namespace std;
int fenwick[2000000][2] = {0}, v[2000010];
void upd(int i, int w, int r) {
	while(i <= 2000000) {
		fenwick[i][w] ^= r;
		i += i&(-i);
	}
}
int getXor(int i, int w) {
	int x = 0;
	while(i>0) {
		x^=fenwick[i][w];
		i -= i&(-i);
	}
	return x;
}
int32_t main () {
	int n, q;
	cin >> n >> q;
	for(int i = 1;i<=n;i++) {
		cin >> v[i];
		upd(ceil(i/2.0), i%2, v[i]);
	}
	for(int i = 1;i<=q;i++) {
		int k;
		cin >> k;
		if(k==1) {
			int j, val;
			cin >> j >> val;
			upd(ceil(j/2.0), j%2, (val ^ v[j]));		
		}
		else {
			int l, u;
			cin >> l >> u;
			if((u - l + 1)%2 == 0)cout<<0<<endl;
			else {
				int a = l%2;
				l-=2;
				int ans = getXor(ceil(u/2.0), a) ^ getXor(ceil(l/2.0), a);cout<<ans<<endl;
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 599 ms 3096 KB Output is correct
2 Correct 599 ms 3012 KB Output is correct
3 Correct 600 ms 3012 KB Output is correct
4 Correct 583 ms 3012 KB Output is correct
5 Correct 591 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -