답안 #703244

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703244 2023-02-26T17:11:03 Z rainboy XORanges (eJOI19_xoranges) C
100 / 100
126 ms 8628 KB
#include <stdio.h>
 
#define N	200000
 
void update(int *ft, int i, int n, int x) {
	while (i < n) {
		ft[i] ^= x;
		i |= i + 1;
	}
}
 
int query(int *ft, int i) {
	int x = 0;
 
	while (i >= 0) {
		x ^= ft[i];
		i &= i + 1, i--;
	}
	return x;
}
 
int main() {
	static int aa[N], ft[2][N];
	int n, q, i;
 
	scanf("%d%d", &n, &q);
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		update(ft[i % 2], i, n, aa[i]);
	}
	while (q--) {
		int t, a, l, r;
 
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d%d", &i, &a), i--;
			update(ft[i % 2], i, n, aa[i] ^ a);
			aa[i] = a;
		} else {
			scanf("%d%d", &l, &r), l--, r--;
			printf("%d\n", (r - l) % 2 != 0 ? 0 : query(ft[l % 2], r) ^ query(ft[l % 2], l - 1));
		}
	}
	return 0;
}

Compilation message

xoranges.c: In function 'main':
xoranges.c:26:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d%d", &n, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~
xoranges.c:28:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
xoranges.c:34:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   scanf("%d", &t);
      |   ^~~~~~~~~~~~~~~
xoranges.c:36:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |    scanf("%d%d", &i, &a), i--;
      |    ^~~~~~~~~~~~~~~~~~~~~
xoranges.c:40:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |    scanf("%d%d", &l, &r), l--, r--;
      |    ^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 440 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 3796 KB Output is correct
2 Correct 112 ms 8564 KB Output is correct
3 Correct 107 ms 8628 KB Output is correct
4 Correct 126 ms 8244 KB Output is correct
5 Correct 105 ms 8252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 440 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 110 ms 3796 KB Output is correct
16 Correct 112 ms 8564 KB Output is correct
17 Correct 107 ms 8628 KB Output is correct
18 Correct 126 ms 8244 KB Output is correct
19 Correct 105 ms 8252 KB Output is correct
20 Correct 107 ms 8396 KB Output is correct
21 Correct 112 ms 8292 KB Output is correct
22 Correct 113 ms 8284 KB Output is correct
23 Correct 101 ms 8208 KB Output is correct
24 Correct 103 ms 8476 KB Output is correct