제출 #275487

#제출 시각아이디문제언어결과실행 시간메모리
275487acmXORanges (eJOI19_xoranges)C++17
100 / 100
207 ms10616 KiB
#include <bits/stdc++.h>
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define oprecision    \
  cout.precision(30); \
  cerr.precision(7);
#define ll long long
#define ld long double
#define ss string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(n) for (int i = 1; i <= n; i++)
#define forlr(l, r) \
  for (int i = l; (l > r ? i >= r : i <= r); (l > r ? i-- : i++))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define pc(x) __builtin_popcount(x)
#define pcll(x) __builtin_popcountll(x)
#define mp(x, y) make_pair(x, y)
#define F first
#define S second
using namespace std;
int n, q, a[200005], t[800005], e[800005];
void upd(int v, int l, int r, int x, int y) {
  if (l == r) {
    if (l & 1)
      t[v] = y;
    else
      e[v] = y;
    return;
  }
  int tm = (l + r) / 2;
  if (x <= tm)
    upd(v + v, l, tm, x, y);
  else
    upd(v + v + 1, tm + 1, r, x, y);
  t[v] = (t[v + v] ^ t[v + v + 1]);
  e[v] = (e[v + v] ^ e[v + v + 1]);
}
int get(int v, int l, int r, int x, int y, int z) {
  if (r < x || y < l) return 0;
  if (x <= l && r <= y) return (z ? t[v] : e[v]);
  int tm = (l + r) / 2;
  return (get(v + v, l, tm, x, y, z) ^ get(v + v + 1, tm + 1, r, x, y, z));
}
int main() {
  speed;
  oprecision;
  // code
  cin >> n >> q;
  forn(n) {
    int x;
    cin >> x;
    upd(1, 1, n, i, x);
  }
  while (q--) {
    int type, l, r;
    cin >> type >> l >> r;
    if (type == 1) {
      upd(1, 1, n, l, r);
    }
    if (type == 2) {
      if ((r - l) % 2)
        cout << 0 << "\n";
      else
        cout << ((l % 2) ? get(1, 1, n, l, r, 1) : get(1, 1, n, l, r, 0))
             << "\n";
    }
  }
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...