Submission #446788

# Submission time Handle Problem Language Result Execution time Memory
446788 2021-07-23T09:15:48 Z fuad27 XORanges (eJOI19_xoranges) C++14
38 / 100
609 ms 4632 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int fenwick[100000][2] = {0}, v[200010];
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 609 ms 4604 KB Output is correct
2 Correct 590 ms 4564 KB Output is correct
3 Correct 585 ms 4624 KB Output is correct
4 Correct 583 ms 4520 KB Output is correct
5 Correct 580 ms 4632 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 -