#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define Sz(x) (int)x.size()
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n, q, a[N];
void solve() {
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
while (q--) {
int tp;
cin >> tp;
if (tp == 1) {
int ind, val;
cin >> ind >> val;
a[ind] = val;
}
else {
int l, r;
cin >> l >> r;
int ans = 0;
for (int i = l; i <= r; i++) {
int k = (r - l + 1);
int R = min(i-l+1,r-i+1), cnt = 0;
if (k % 2 == 0) cnt = (R * (R + 1));
else {
if (R == (k + 1) / 2) cnt = (R - 1) * (R - 2) / 2 + R;
else cnt = (R * (R + 1)) + R * (k - 2 * R);
}
if (cnt % 2 == 1) ans ^= a[i];
}
cout << ans << '\n';
}
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin >> t;
while ( t-- ) {
solve();
cout << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |