Submission #761189

# Submission time Handle Problem Language Result Execution time Memory
761189 2023-06-19T10:43:52 Z KN200711 XORanges (eJOI19_xoranges) C++14
100 / 100
108 ms 5156 KB
# include <bits/stdc++.h>
using namespace std;

int seg[2][400010];
int arr[200001], gj[200001], gn[200001];
const int MXN = 1e5 + 1;

void build(int lf, int rg, int nd, int ct) {
	if(lf == rg) {
		if(ct == 1) seg[ct][nd] = gj[lf];
		else seg[ct][nd] = gn[lf];
	} else {
		int mid = (lf + rg)/2;
		build(lf, mid, 2*nd+1, ct);
		build(mid+1, rg, 2*nd+2, ct);
		seg[ct][nd] = seg[ct][2*nd+1] ^ seg[ct][2*nd+2];
	}
}

void upd(int lf, int rg, int pos, int nd, int val, int ct) {
	if(lf == rg) {
		seg[ct][nd] = val;
	} else {
		int mid = (lf + rg)/2;
		if(pos <= mid) upd(lf, mid, pos, 2*nd+1, val, ct);
		else upd(mid+1, rg, pos, 2*nd+2, val, ct);
		seg[ct][nd] = seg[ct][2*nd+1] ^ seg[ct][2*nd+2];
	}
}

int qry(int lf, int rg, int clf, int crg, int nd, int ct) {
	if(clf > rg || lf > crg) return 0;
	if(clf <= lf && rg <= crg) return seg[ct][nd];
	int mid = (lf + rg)/2;
	return qry(lf, mid, clf, crg, 2*nd+1, ct) ^ qry(mid+1, rg, clf, crg, 2*nd+2, ct);	
}

int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	
	for(int i=0;i<N;i++) {
		scanf("%d", &arr[i]);
		if(i&1) gj[i/2] = arr[i];
		else gn[i/2] = arr[i];
	}
	build(0, MXN, 0, 0);
	build(0, MXN, 0, 1);
	
	while(Q--) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if(a == 2) {
			b--;
			c--;
			if((c - b)&1) printf("0\n");
			else {
				printf("%d\n", qry(0, MXN, b/2, c/2, 0, b&1));
			}
		} else {
			b--;
			upd(0, MXN, b/2, 0, c, b&1);
		}
	}
	return 0;
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf("%d %d", &N, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~~
xoranges.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d", &arr[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
xoranges.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   scanf("%d %d %d", &a, &b, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 2 ms 2260 KB Output is correct
5 Correct 2 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2260 KB Output is correct
2 Correct 2 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 2 ms 2260 KB Output is correct
5 Correct 2 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 2 ms 2260 KB Output is correct
5 Correct 2 ms 2260 KB Output is correct
6 Correct 2 ms 2260 KB Output is correct
7 Correct 2 ms 2260 KB Output is correct
8 Correct 2 ms 2260 KB Output is correct
9 Correct 2 ms 2260 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 4 ms 2388 KB Output is correct
12 Correct 5 ms 2388 KB Output is correct
13 Correct 4 ms 2428 KB Output is correct
14 Correct 5 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 5040 KB Output is correct
2 Correct 108 ms 5076 KB Output is correct
3 Correct 104 ms 5012 KB Output is correct
4 Correct 104 ms 5156 KB Output is correct
5 Correct 96 ms 5000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 2 ms 2260 KB Output is correct
5 Correct 2 ms 2260 KB Output is correct
6 Correct 2 ms 2260 KB Output is correct
7 Correct 2 ms 2260 KB Output is correct
8 Correct 2 ms 2260 KB Output is correct
9 Correct 2 ms 2260 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 4 ms 2388 KB Output is correct
12 Correct 5 ms 2388 KB Output is correct
13 Correct 4 ms 2428 KB Output is correct
14 Correct 5 ms 2388 KB Output is correct
15 Correct 104 ms 5040 KB Output is correct
16 Correct 108 ms 5076 KB Output is correct
17 Correct 104 ms 5012 KB Output is correct
18 Correct 104 ms 5156 KB Output is correct
19 Correct 96 ms 5000 KB Output is correct
20 Correct 98 ms 4500 KB Output is correct
21 Correct 97 ms 4432 KB Output is correct
22 Correct 102 ms 4472 KB Output is correct
23 Correct 97 ms 4996 KB Output is correct
24 Correct 101 ms 5044 KB Output is correct