aboutsummaryrefslogtreecommitdiff
path: root/05_range_queries/range_xor_queries_1650.cpp
blob: e6a450081a5f3d9e3dc069f2948378a4f38b6d33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
	size_t n, q;
	std::cin >> n >> q;
	std::vector<int> p(n);
	for (size_t i = 0; i < n; i++)
		std::cin >> p[i];
	for (size_t i = 1; i < n; i++)
		p[i] ^= p[i-1];
	for (size_t i = 0; i < q; i++) {
		int x, k, s;
		std::cin >> x >> k;
		s = p[k-1];
		if (x > 1) s ^= p[x-2];
		std::cout << s << "\n";
	}
}

Generated with cgit - Back to sebastiano.tronto.net