Submission #446770

# Submission time Handle Problem Language Result Execution time Memory
446770 2021-07-23T08:46:52 Z fuad27 XORanges (eJOI19_xoranges) C++14
0 / 100
95 ms 6736 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct fenwick {
	int v[100010] = {0};
	void update(int i, int val) {
		i++;
		while(i < 100010) {
			v[i] ^= val;
			i += i&(-i);
		}
	}
	int getXor(int i) {
		int x = 0;
		while(i > 0) {
			x ^= v[i];
			i -= i & (-i);
		}
		return x;
	}
};
int32_t main () {
	int n, q;
	cin >> n >> q;
	vector<int> v(n, 0);
	fenwick x;
	fenwick xodd;
	for(int i = 1;i<=n;i++) {
		int p;
		cin >> p;
		v[i-1] = p;
		x.update(i, p);
		if(i%2 == 0) {
			xodd.update(i, p);
		}
	}
	while(q--) {
		int k;
		cin >> k;
		if(k == 1) {
			int i, val;
			cin >> i >> val;
			x.update(i, val ^ v[i-1]);
			if(i%2 == 1) {
				xodd.update(i, val ^ v[i-1]);
			}
			v[i-1] = val;
		}
		else {
			int l, u;
			cin >> l >> u;
			if((u - l)%2 == 0) {
				if(l%2 == 1) {
					int ans = xodd.getXor(u) ^ xodd.getXor(l-1);cout<<ans<<endl;
				}
				else {
					int ans = x.getXor(u) ^ xodd.getXor(u) ^ x.getXor(l-1) ^ xodd.getXor(l-1);cout<<ans<<endl;
 
				}
			}
			else {
				cout<<0<<endl;
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 95 ms 6736 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1740 KB Output isn't correct
2 Halted 0 ms 0 KB -