#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define pb push_back
#define pob pop_back
#define pll pair <long long, long long>
#define pld pair <long double, long double>
#define ll long long
#define ull unsigned long long
#define ld long double
#define int ll
#define Int int
#define itn int
#define nit int
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define sz(s) s.size()
#define skip continue
#define equal jlij
#define y0 ijl
#define y1 hjk
#define friend trs
#define delete bae
#define div aber
#define exp earb
#define new aer
#define find find
using namespace std;
const int N = 1e6 + 7;
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
int t[N];
int t0[N];
int t1[N];
int a[N];
void build(int v, int tl, int tr) {
if (tl == tr) {
t[v] = a[tl];
if (tl % 2 == 0)t0[v] = a[tl];
else t1[v] = a[tl];
return;
}
int mid = (tl + tr) / 2;
build(v * 2, tl, mid), build(v * 2 + 1, mid + 1, tr);
t[v] = (t[v * 2] ^ t[v * 2 + 1]);
t0[v] = (t0[v * 2] ^ t0[v * 2 + 1]), t1[v] = (t1[v * 2] ^ t1[v * 2 + 1]);
}
int get(int v, int tl, int tr, int l, int r) {
if (tr < l || tl > r)return 0;
if (tl >= l && tr <= r)return t[v];
int mid = (tl + tr) / 2;
return (get(v * 2, tl, mid, l, r) ^ get(v * 2 + 1, mid + 1, tr, l, r));
}
int get0(int v, int tl, int tr, int l, int r) {
if (tr < l || tl > r)return 0;
if (tl >= l && tr <= r)return t0[v];
int mid = (tl + tr) / 2;
return (get0(v * 2, tl, mid, l, r) ^ get0(v * 2 + 1, mid + 1, tr, l, r));
}
int get1(int v, int tl, int tr, int l, int r) {
if (tr < l || tl > r)return 0;
if (tl >= l && tr <= r)return t1[v];
int mid = (tl + tr) / 2;
return (get1(v * 2, tl, mid, l, r) ^ get1(v * 2 + 1, mid + 1, tr, l, r));
}
void update(int v, int tl, int tr, int pos, int x) {
if (tl == tr) {
t[v] = x;
if (tl % 2 == 0)t0[v] = x, t1[v] = 0;
else t1[v] = x, t0[v] = 0;
return;
}
int mid = (tl + tr) / 2;
if (pos <= mid)update(v * 2, tl, mid, pos, x);
else update(v * 2 + 1, mid + 1, tr, pos, x);
t[v] = (t[v * 2] ^ t[v * 2 + 1]);
t0[v] = (t0[v * 2] ^ t0[v * 2 + 1]), t1[v] = (t1[v * 2] ^ t1[v * 2 + 1]);
}
void solve() {
int n, q;
cin >> n >> q;
for (int i = 1;i <= n;i++)cin >> a[i];
build(1, 1, n);
while (q--) {
int type, l, r, pos, x;
cin >> type;
if (type == 1) {
cin >> pos >> x;
update(1, 1, n, pos, x);
}
else {
cin >> l >> r;
if ((r - l) % 2 == 1)cout << 0 << "\n";
else {
x = get(1, 1, n, l, r);
if (l % 2 == 1)cout << (x ^ (get0(1, 1, n, l, r))) << "\n";
else cout << (x ^ (get1(1, 1, n, l, r))) << "\n";
}
}
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
t = 1;
while (t--)solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
4 ms |
844 KB |
Output is correct |
12 |
Correct |
4 ms |
844 KB |
Output is correct |
13 |
Correct |
4 ms |
844 KB |
Output is correct |
14 |
Correct |
5 ms |
844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
282 ms |
15388 KB |
Output is correct |
2 |
Correct |
227 ms |
17148 KB |
Output is correct |
3 |
Correct |
213 ms |
17096 KB |
Output is correct |
4 |
Correct |
161 ms |
17036 KB |
Output is correct |
5 |
Correct |
161 ms |
17148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
4 ms |
844 KB |
Output is correct |
12 |
Correct |
4 ms |
844 KB |
Output is correct |
13 |
Correct |
4 ms |
844 KB |
Output is correct |
14 |
Correct |
5 ms |
844 KB |
Output is correct |
15 |
Correct |
282 ms |
15388 KB |
Output is correct |
16 |
Correct |
227 ms |
17148 KB |
Output is correct |
17 |
Correct |
213 ms |
17096 KB |
Output is correct |
18 |
Correct |
161 ms |
17036 KB |
Output is correct |
19 |
Correct |
161 ms |
17148 KB |
Output is correct |
20 |
Correct |
188 ms |
16548 KB |
Output is correct |
21 |
Correct |
189 ms |
16632 KB |
Output is correct |
22 |
Correct |
171 ms |
16460 KB |
Output is correct |
23 |
Correct |
160 ms |
17072 KB |
Output is correct |
24 |
Correct |
164 ms |
17088 KB |
Output is correct |