Submission #446789

# Submission time Handle Problem Language Result Execution time Memory
446789 2021-07-23T09:16:42 Z fuad27 XORanges (eJOI19_xoranges) C++14
38 / 100
693 ms 4628 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int fenwick[2000000][2] = {0}, v[2000010];
void upd(int i, int w, int r) {
	while(i <= 100000) {
		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 3 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 610 ms 4628 KB Output is correct
2 Correct 649 ms 4572 KB Output is correct
3 Correct 693 ms 4612 KB Output is correct
4 Correct 593 ms 4556 KB Output is correct
5 Correct 577 ms 4548 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 -