Submission #625254

#TimeUsernameProblemLanguageResultExecution timeMemory
625254lovrotXORanges (eJOI19_xoranges)C++11
100 / 100
145 ms9584 KiB
#include <bits/stdc++.h> 
#include <unistd.h>

#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define pri(i, poc, n, pov) for(int i = (int) poc; i < (int) n; i += (int) pov)
#define od(i, poc, n, pov) for(int i = (int) poc; i > (int) n; i -= (int) pov)

using namespace std;

const int LOG = 18;
const int OFF = (1 << LOG);

struct node{ 
	int xr[2] = {0, 0};
} tour[OFF * 2];

int n, q; 

void update(int x, int val){
	x += OFF; 
	tour[x].xr[x % 2] = val;
	x >>= 1;
	while(x){ 
		pri(i, 0, 2, 1)
			tour[x].xr[i] = tour[x * 2].xr[i] ^ tour[x * 2 + 1].xr[i];
		x >>= 1;
	}
}

int query(int b, int l, int r, int lo = 0, int hi = OFF, int x = 1){ 
	if(r <= lo || hi <= l) return 0;
	if(l <= lo && hi <= r) return tour[x].xr[b];
	int mi = (lo + hi) / 2;
	return query(b, l, r, lo, mi, x * 2) ^ query(b, l, r, mi, hi, x * 2 + 1);
}

int main(){ 
	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);

	cin >> n >> q;

	pri(i, 0, n, 1){
		int x;
		cin >> x;
		update(i, x);
	}

	pri(i, 0, q, 1){ 
		int t, x, y;
		cin >> t >> x >> y;
		if(t == 1){
			update(x - 1, y); 
		} else { 
			x--;
			y--;
			int p = (y - x + 1) % 2;
			if(!p)
				cout << 0 << "\n";
			else
				cout << query(x % 2, x, y + 1) << "\n";
		}
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...