#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define sz(x) (int)x.size()
#define MASK(i) ((1LL) << (i))
#define all(x) x.begin(), x.end()
#define BIT(x, i) ((x) >> (i) & (1LL))
#define dbg(...) cerr << "#" << __LINE__ << ":[" << #__VA_ARGS__ \
<< "] = [" ,DBG(__VA_ARGS__)
string to_string(const string& s) { return '"' + s + '"'; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...);
}
template <class T>
inline bool maximize(T &a, const T &b) { return (a < b ? (a = b, 1) : 0); }
template <class T>
inline bool minimize(T &a, const T &b) { return (a > b ? (a = b, 1) : 0); }
const int MAXN = 2e5 + 6;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int n, q, a[MAXN];
struct FenwickTree {
int n;
vector<int> bit;
FenwickTree (int _n) {
n = _n;
bit.assign(n + 7, 0);
}
void update (int i, int x) {
for (; i <= n; i += i & -i) bit[i] ^= x;
}
int get(int i) {
int res = 0;
for (; i > 0; i -= i & -i) res ^= bit[i];
return res;
}
};
void solve() {
cin >> n >> q;
FenwickTree itEven(n), itOdd(n);
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i & 1) itOdd.update(i, a[i]);
else itEven.update(i, a[i]);
}
while (q--) {
int t, u, v;
cin >> t >> u >> v;
if (t == 1) {
if (u & 1) itOdd.update(u, a[u]);
else itEven.update(u, a[u]);
a[u] = v;
if (u & 1) itOdd.update(u, a[u]);
else itEven.update(u, a[u]);
}
else {
if ((v - u + 1) % 2 == 0) cout << 0 << '\n';
else {
if (u & 1) cout << (itOdd.get(v) ^ itOdd.get(u - 1)) << '\n';
else cout << (itEven.get(v) ^ itEven.get(u - 1)) << '\n';
}
}
}
}
#define TASK ""
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(TASK".inp", "r", stdin);
//freopen(TASK".out", "w", stdout);
int ntest = 1;
//cin >> ntest;
while (ntest--) solve();
return 0;
}
//612
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
83 ms |
8688 KB |
Output is correct |
2 |
Correct |
82 ms |
11004 KB |
Output is correct |
3 |
Correct |
79 ms |
11152 KB |
Output is correct |
4 |
Correct |
83 ms |
10824 KB |
Output is correct |
5 |
Correct |
71 ms |
10828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
83 ms |
8688 KB |
Output is correct |
16 |
Correct |
82 ms |
11004 KB |
Output is correct |
17 |
Correct |
79 ms |
11152 KB |
Output is correct |
18 |
Correct |
83 ms |
10824 KB |
Output is correct |
19 |
Correct |
71 ms |
10828 KB |
Output is correct |
20 |
Correct |
72 ms |
10836 KB |
Output is correct |
21 |
Correct |
82 ms |
10708 KB |
Output is correct |
22 |
Correct |
70 ms |
10760 KB |
Output is correct |
23 |
Correct |
73 ms |
11084 KB |
Output is correct |
24 |
Correct |
67 ms |
11100 KB |
Output is correct |