Your code here...
void solve() { int n , q ; cin >> n >> q ; vector arr(n); for (int i = 0 ; i < n ; i++) { cin >> arr[i]; } while (n & (n — 1)) { n++; arr.pb(0); } vector seg(2 * n, 0 ); for (int i = 0 ; i < n ; i++) { seg[n + i] = arr[i]; } for (int i = n — 1 ; i >= 1 ; i--) { seg[i] = (seg[2 * i] ^ seg[2 * i + 1]); } auto query = [&](int l , int r) { l += n; r += n; ll ans = 0 ; while (l < r) { if (l & 1) ans = (ans ^ seg[l++]); if (r & 1) ans = (ans ^ seg[--r]); l /= 2; r /= 2; } return ans ; }; auto update = [&](int pos , int val) { pos += n; seg[pos] = val ; while (pos > 1) { pos /= 2; seg[pos] = (seg[2 * pos] ^ seg[2 * pos + 1]); } }; while (q--) { int type = 2 , l, r ; cin >> l >> r ; if (type == 2) { l--; r; cout << query(l, r) << endl; } else { update(--l, r); }
}
}