Submission #929496

# Submission time Handle Problem Language Result Execution time Memory
929496 2024-02-18T05:59:16 Z erkhem XORanges (eJOI19_xoranges) C++14
0 / 100
99 ms 20724 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'
#define ff first
#define ss second
#define rev reverse
#define pb push_back
#define all(a) a.begin(), a.end()
#define maxx(a, b) a = max(a, b);
#define minn(a, b) a = min(a, b);
#define fastio cin.tie(0)->sync_with_stdio(0)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<string> vs;

const int mod = 1e9 + 7;
const int inf = 1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

vi a, a1;
vi sum, sum1;

void build(int id, int L, int R) {
	if (L == R) {
		sum[id] = a[L];
		return;
	}
	int M = (L + R) / 2, x = 2 * id + 1, y = 2 * id + 2;
	build(x, L, M);
	build(y, M + 1, R);
	sum[id] = sum[x] ^ sum[y];
}

void update(int id, int L, int R, int i, int k) {
	if (L == R) {
		sum[id] = k;
		return;
	}
	int M = (L + R) / 2, x = 2 * id + 1, y = x + 1;
	if (i <= M) {
		update(x, L, M, i, k);
	} else {
		update(y, M + 1, R, i, k);
	}
	sum[id] = sum[x] ^ sum[y];
}

long long query(int id, int L, int R, int l, int r) {
	if (L == l && r == R) {
		return sum[id];
	}
	int M = (L + R) / 2, x = 2 * id + 1, y = x + 1;
	if (r <= M)
		return query(x, L, M, l, r);
	if (M + 1 <= l)
		return query(y, M + 1, R, l, r);
	return query(x, L, M, l, M) ^ query(y, M + 1, R, M + 1, r);
}

void build1(int id, int L, int R) {
	if (L == R) {
		sum1[id] = a1[L];
		return;
	}
	int M = (L + R) / 2, x = 2 * id + 1, y = 2 * id + 2;
	build1(x, L, M);
	build1(y, M + 1, R);
	sum1[id] = sum1[x] ^ sum1[y];
}

void update1(int id, int L, int R, int i, int k) {
	if (L == R) {
		sum1[id] = k;
		return;
	}
	int M = (L + R) / 2, x = 2 * id + 1, y = x + 1;
	if (i <= M) {
		update1(x, L, M, i, k);
	} else {
		update1(y, M + 1, R, i, k);
	}
	sum1[id] = sum1[x] ^ sum1[y];
}

long long query1(int id, int L, int R, int l, int r) {
	if (L == l && r == R) {
		return sum1[id];
	}
	int M = (L + R) / 2, x = 2 * id + 1, y = x + 1;
	if (r <= M)
		return query1(x, L, M, l, r);
	if (M + 1 <= l)
		return query1(y, M + 1, R, l, r);
	return query1(x, L, M, l, M) ^ query1(y, M + 1, R, M + 1, r);
}

int32_t main() {
	fastio;
	int n, q;
	cin >> n >> q;
	int f = n;
	sum.resize(4 * n + 4);
	sum1.resize(4 * n + 4);
	int n1 = n / 2;
	n -= n1;
	//n1 sondgoi
	//n tegsh
	rep1(i, f) {
		int x;
		cin >> x;
		if (i % 2 == 1) {
			a.pb(x);
		}
		else a1.pb(x);
	}
	build(0, 0, n - 1);
	build1(0, 0, n1 - 1);
	while (q--) {
		int c, l, r;
		cin >> c >> l >> r;
		if (c == 1) {
			l--;
			if (l % 2 == 0) update(0, 0, n - 1, l / 2, r);
			else update1(0, 0, n1 - 1, l / 2, r);
		}
		else {
			l--;
			r--;
			if ((l - r + 1) % 2 == 0) cout << 0 << endl;
			else cout << query1(0, 0, n1 - 1, l / 2, r / 2) << endl;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 20724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -