Submission #929233

# Submission time Handle Problem Language Result Execution time Memory
929233 2024-02-18T04:03:06 Z erkhem XORanges (eJOI19_xoranges) C++14
12 / 100
70 ms 17088 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;
vi sum;

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);
}

int32_t main() {
	fastio;
	int n, q;
	cin >> n >> q;
	a.resize(n);
	sum.resize(4 * n + 10);
	vi p(n);
	rep(i, n) {
		cin >> a[i];
	}
	p[0] = a[0];
	rep1(i, n - 1) {
		p[i] = p[i - 1] ^ a[i];
	}
	build(0, 0, n - 1);
	vector<pair<int, pii>> v;
	bool b = 0;
	while (q--) {
		int c, l, r;
		cin >> c >> l >> r;
		v.pb({c, {l, r}});
		if (c == 1) b = 1;
	}
	if (b) {
		for (auto x : v) {
			int c = x.ff;
			int l = x.ss.ff;
			int r = x.ss.ss;
			if (c == 1) {
				update(0, 0, n - 1, l - 1, r);
			}
			else {
				int ans = 0;
				for (int i = l; i <= r; i++) {
					for (int j = i; j <= r; j++) {
						ans ^= query(0, 0, n - 1, i - 1, j - 1);
					}
				}
				cout << ans << endl;
			}
		}
	}
	if (!b) {
		for (auto x : v) {
			int l = x.ss.ff;
			int r = x.ss.ss;
			cout << p[r] - p[l - 1] << endl;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 500 KB Output is correct
4 Correct 17 ms 348 KB Output is correct
5 Correct 15 ms 348 KB Output is correct
# 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 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 500 KB Output is correct
4 Correct 17 ms 348 KB Output is correct
5 Correct 15 ms 348 KB Output is correct
6 Incorrect 1 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 17088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 500 KB Output is correct
4 Correct 17 ms 348 KB Output is correct
5 Correct 15 ms 348 KB Output is correct
6 Incorrect 1 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -