답안 #467134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467134 2021-08-21T18:54:30 Z radaiosm7 XORanges (eJOI19_xoranges) C++
100 / 100
134 ms 3816 KB
#include <bits/stdc++.h>
using namespace std;
int n, q, i, a, b, quer;
int c[200005];
int fen[2][200005];

void Update() {
  for (int indx=a; indx <= n; indx += (indx&(-indx))) fen[a&1][indx] ^= b^c[a];
  c[a] = b;
}

int Query(int indx) {
  int x = 0;
  for (; indx > 0; indx -= (indx&(-indx))) x ^= fen[a&1][indx];
  return x;
}

int main() {
  scanf("%d%d", &n, &q);
  for (i=1; i <= n; ++i) scanf("%d", &c[i]);
  for (i=1; i <= n; ++i) {
    a = i;
    b = c[i];
    c[i] = 0;
    Update();
  }

  fen[0][0] = 0;
  fen[1][0] = 0;

  while (q--) {
    scanf("%d%d%d", &quer, &a, &b);
    if (quer == 1) Update();
    else if ((a&1) != (b&1)) printf("0\n");
    else printf("%d\n", Query(b)^Query(a-1));
  }

  return 0;
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d%d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:20:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   for (i=1; i <= n; ++i) scanf("%d", &c[i]);
      |                          ~~~~~^~~~~~~~~~~~~
xoranges.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d%d%d", &quer, &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 3808 KB Output is correct
2 Correct 125 ms 3780 KB Output is correct
3 Correct 115 ms 3728 KB Output is correct
4 Correct 115 ms 3780 KB Output is correct
5 Correct 106 ms 3816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 134 ms 3808 KB Output is correct
16 Correct 125 ms 3780 KB Output is correct
17 Correct 115 ms 3728 KB Output is correct
18 Correct 115 ms 3780 KB Output is correct
19 Correct 106 ms 3816 KB Output is correct
20 Correct 111 ms 3164 KB Output is correct
21 Correct 114 ms 3220 KB Output is correct
22 Correct 115 ms 3140 KB Output is correct
23 Correct 115 ms 3692 KB Output is correct
24 Correct 108 ms 3648 KB Output is correct