답안 #255463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255463 2020-08-01T05:30:31 Z lani1akea XORanges (eJOI19_xoranges) C++17
100 / 100
165 ms 11460 KB
#include <bits/stdc++.h>

#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'

using namespace std;

const int MOD = 1e9 + 7;
const int N = 2 * 1e5 + 10;

int n, q, a[N], t1[4*N], t2[4*N];

void build(int x, int l, int r) {
  if (l == r) {
    if (l % 2) t1[x] = a[l];
    else t2[x] = a[l];
    return;
  }
  int m = (l + r) / 2;
  build(x*2, l, m);
  build(x*2+1, m+1, r);
  t1[x] = t1[x*2] ^ t1[x*2+1];
  t2[x] = t2[x*2] ^ t2[x*2+1];
}

void update(int x, int l, int r, int i, int v) {
  if (l == r) {
    if (i % 2) t1[x] = v;
    else t2[x] = v;
    return;
  }
  int m = (l + r) / 2;
  if (i > m) update(2*x+1, m+1, r, i, v);
  else update(2*x, l, m, i, v);
  t1[x] = t1[2*x] ^ t1[2*x+1];
  t2[x] = t2[2*x] ^ t2[2*x+1];
}

int get(int x, int lx, int rx, int l, int r, int type) {
  if (lx > r or rx < l) return 0;
  if (lx >= l and rx <= r) {
    if (type & 1) return t1[x];
    else return t2[x];
  }
  int m = (lx + rx) / 2;
  return get(2*x, lx, m, l, r, type) ^ get(2*x+1, m+1, rx, l, r, type);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  build(1, 0, n - 1);

  while(q--) {
    int t, i, j;
    cin >> t >> i >> j;
    if (t&1) {
      update(1, 0, n-1, i-1, j);
    } else {
      if (i % 2 != j % 2)
        cout << "0\n";
      else
        cout << get(1, 0, n-1, i-1, j-1, (i-1)%2) << endl;
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 4 ms 640 KB Output is correct
12 Correct 4 ms 640 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 3 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 11324 KB Output is correct
2 Correct 165 ms 11460 KB Output is correct
3 Correct 146 ms 11256 KB Output is correct
4 Correct 136 ms 11004 KB Output is correct
5 Correct 154 ms 11100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 4 ms 640 KB Output is correct
12 Correct 4 ms 640 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 3 ms 640 KB Output is correct
15 Correct 152 ms 11324 KB Output is correct
16 Correct 165 ms 11460 KB Output is correct
17 Correct 146 ms 11256 KB Output is correct
18 Correct 136 ms 11004 KB Output is correct
19 Correct 154 ms 11100 KB Output is correct
20 Correct 163 ms 11000 KB Output is correct
21 Correct 144 ms 11004 KB Output is correct
22 Correct 153 ms 11088 KB Output is correct
23 Correct 140 ms 10872 KB Output is correct
24 Correct 141 ms 11000 KB Output is correct