Submission #973268

# Submission time Handle Problem Language Result Execution time Memory
973268 2024-05-01T17:02:49 Z terracottalite XORanges (eJOI19_xoranges) C++14
100 / 100
106 ms 7852 KB
#include <stdio.h>

int fw[2][200005] = { { 0 } };
int n, q;

int query(int r, int op) {
	int ans = 0;
	while (r > 0) {
		ans ^= fw[op][r];
		r -= r & (-r);
	}
	return ans;
}

void update(int p, int v) {
	int op = p&1;
	int av = query(p, op)^query(p-1, op)^v;
	while (p <= n) {
		fw[op][p] ^= av;
		p += p & (-p);
	}
}

int main()
{
	scanf("%d %d", &n, &q);

	for (int i=1;i<=n;i++) {
		int x;
		scanf("%d", &x);
		update(i, x);
	}

	while (q--) {
		int action;
		scanf("%d", &action);

		if (action == 1) {
			int i, v;
			scanf("%d %d", &i, &v);

			update(i, v);
		} else {
			int l, u;
			scanf("%d %d", &l, &u);

			if ((u-l+1)%2 == 0) {
				puts("0");
				continue;
			}

			int op = l%2;

			printf("%d\n", query(u, op)^query(l-1, op));
		}
	}
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d %d", &n, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~
xoranges.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
xoranges.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%d", &action);
      |   ~~~~~^~~~~~~~~~~~~~~
xoranges.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |    scanf("%d %d", &i, &v);
      |    ~~~~~^~~~~~~~~~~~~~~~~
xoranges.cpp:45:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |    scanf("%d %d", &l, &u);
      |    ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 7844 KB Output is correct
2 Correct 80 ms 7852 KB Output is correct
3 Correct 81 ms 7764 KB Output is correct
4 Correct 79 ms 7624 KB Output is correct
5 Correct 86 ms 7544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 82 ms 7844 KB Output is correct
16 Correct 80 ms 7852 KB Output is correct
17 Correct 81 ms 7764 KB Output is correct
18 Correct 79 ms 7624 KB Output is correct
19 Correct 86 ms 7544 KB Output is correct
20 Correct 106 ms 7568 KB Output is correct
21 Correct 82 ms 7508 KB Output is correct
22 Correct 79 ms 7688 KB Output is correct
23 Correct 77 ms 7504 KB Output is correct
24 Correct 78 ms 7556 KB Output is correct