답안 #935085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935085 2024-02-28T15:12:12 Z ind1v XORanges (eJOI19_xoranges) C++11
100 / 100
105 ms 8788 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

struct fenwick_tree {
  int f[N];
  
  fenwick_tree() {
    memset(f, 0, sizeof(f));
  }
  
  void upd(int i, int x) {
    for (; i < N; i += i & -i) {
      f[i] ^= x;
    }
  }
  
  int get(int i) {
    int res = 0;
    for (; i > 0; i -= i & -i) {
      res ^= f[i];
    }
    return res;
  }
  
  int get(int l, int r) {
    return get(r) ^ get(l - 1);
  }
};

int n, q;
int a[N];
fenwick_tree ft[2];

void upd(int i, int j) {
  ft[i & 1].upd(i, a[i]);
  a[i] = j;
  ft[i & 1].upd(i, a[i]);
}

int get(int l, int u) {
  if ((l & 1) != (u & 1)) {
    return 0;
  }
  return ft[l & 1].get(l, u);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ft[i & 1].upd(i, a[i]);
  }
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int i, j;
      cin >> i >> j;
      upd(i, j);
    } else if (t == 2) {
      int l, u;
      cin >> l >> u;
      cout << get(l, u) << '\n';
    }
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2668 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2668 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2652 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 8772 KB Output is correct
2 Correct 84 ms 8788 KB Output is correct
3 Correct 105 ms 8788 KB Output is correct
4 Correct 65 ms 8400 KB Output is correct
5 Correct 65 ms 8324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2668 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2652 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2800 KB Output is correct
15 Correct 71 ms 8772 KB Output is correct
16 Correct 84 ms 8788 KB Output is correct
17 Correct 105 ms 8788 KB Output is correct
18 Correct 65 ms 8400 KB Output is correct
19 Correct 65 ms 8324 KB Output is correct
20 Correct 66 ms 8456 KB Output is correct
21 Correct 66 ms 8528 KB Output is correct
22 Correct 65 ms 8532 KB Output is correct
23 Correct 67 ms 8272 KB Output is correct
24 Correct 66 ms 8272 KB Output is correct