#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
const int MAXN = 2e5 + 10;
int t[MAXN << 2][2];
int n, q;
void upd(int pos, int val, int v = 1, int tl = 1, int tr = n) {
if(tl == tr) {
t[v][pos & 1] = val;
return;
}
int tm = tl + tr >> 1;
if(pos <= tm) upd(pos, val, v << 1, tl, tm);
else upd(pos, val, v << 1 | 1, tm + 1, tr);
for(int j = 0; j < 2; ++j)
t[v][j] = t[v << 1][j] ^ t[v << 1 | 1][j];
}
int get(int l, int r, int v = 1, int tl = 1, int tr = n) {
if(l <= tl && tr <= r) return t[v][l & 1];
if(l > tr || r < tl) return 0;
int tm = tl + tr >> 1;
return get(l, r, v << 1, tl, tm) ^ get(l, r, v << 1 | 1, tm + 1, tr);
}
void solve() {
cin >> n >> q;
for(int i = 1; i <= n; ++i) {
int x;
cin >> x;
upd(i, x);
}
for(int i = 1; i <= q; ++i) {
int type, l, r;
cin >> type >> l >> r;
if(type == 1) upd(l, r);
else cout << get(l, r) << '\n';
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
///cin >> T;
while(T--) solve();///, cout << '\n';
return 0;
}
Compilation message
xoranges.cpp: In function 'void upd(int, int, int, int, int)':
xoranges.cpp:33:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
33 | int tm = tl + tr >> 1;
| ~~~^~~~
xoranges.cpp: In function 'int get(int, int, int, int, int)':
xoranges.cpp:43:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
43 | int tm = tl + tr >> 1;
| ~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
250 ms |
6764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |