답안 #1067632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067632 2024-08-20T22:07:29 Z raduv XORanges (eJOI19_xoranges) C++14
100 / 100
102 ms 8788 KB
#include <bits/stdc++.h>
const int MAXN = 2e5;
using namespace std;
int aib[2][MAXN + 1];
int v[MAXN + 1];
void update(int poz, int x, int n){
  int i;
  for( i = poz; i <= n; i += i & -i){
    aib[poz & 1][i] ^= x;
  }
}
int query(int poz, int par){
  int rez = 0, i;
  for( i = poz; i > 0; i = (i & (i - 1))){
    rez ^= aib[par][i];
  }
  return rez;
}
int main(){
  int n, q, i, op, l, r;
  scanf("%d%d", &n, &q);
  for( i = 1; i <= n; i++ ){
    scanf("%d", &v[i]);
    update(i, v[i], n);
  }
  for( i = 0; i < q; i++ ){
    scanf("%d%d%d", &op, &l, &r);
    if(op == 1){
      update(l, v[l], n);
      update(l, r, n);
      v[l] = r;
    }
    else{
      if( (r - l) & 1 ){
        printf("0\n");
      }
      else{
        printf("%d\n", query(r, r & 1) ^ query(l - 1, l & 1));
      }
    }
  }
  return 0;
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d%d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d", &v[i]);
      |     ~~~~~^~~~~~~~~~~~~
xoranges.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d%d%d", &op, &l, &r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 8788 KB Output is correct
2 Correct 62 ms 8788 KB Output is correct
3 Correct 62 ms 8784 KB Output is correct
4 Correct 63 ms 8420 KB Output is correct
5 Correct 64 ms 8308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 62 ms 8788 KB Output is correct
16 Correct 62 ms 8788 KB Output is correct
17 Correct 62 ms 8784 KB Output is correct
18 Correct 63 ms 8420 KB Output is correct
19 Correct 64 ms 8308 KB Output is correct
20 Correct 66 ms 8528 KB Output is correct
21 Correct 61 ms 8532 KB Output is correct
22 Correct 102 ms 8532 KB Output is correct
23 Correct 61 ms 8276 KB Output is correct
24 Correct 59 ms 8312 KB Output is correct