#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
int n, q;
namespace sub123{
void solve(){
vector<int>a(n + 1);
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int _ = 0; _ < q; _++){
int _t, u, v;
cin >> _t >> u >> v;
if(_t == 1){
a[u] = v;
}
else{
int ans = 0;
for(int i = u; i <= v; i++){
if((~(i - u) & 1) && (~(v - i) & 1)){
ans ^= a[i];
}
}
cout << ans << "\n";
}
}
}
}
namespace sub45{
const int lim = 2e5 + 5;
int st[lim << 2][2];
void fix(int id){
st[id][0] = st[id << 1][0] ^ st[id << 1 | 1][0];
st[id][1] = st[id << 1][1] ^ st[id << 1 | 1][1];
}
void update(int id, int l, int r, int p, int x){
if(l == r){
st[id][l & 1] = x;
return;
}
int m = (l + r) >> 1;
if(m < p){
update(id << 1 | 1, m + 1, r, p, x);
}
else{
update(id << 1, l, m, p, x);
}
st[id][0] = st[id << 1][0] ^ st[id << 1 | 1][0];
st[id][1] = st[id << 1][1] ^ st[id << 1 | 1][1];
}
int get(const int type, int id, int l, int r, int u, int v){
if(l > v || r < u){
return 0;
}
if(u <= l && v >= r){
return st[id][type];
}
int m = (l + r) >> 1;
return get(type, id << 1, l, m, u, v) ^ get(type, id << 1 | 1, m + 1, r, u, v);
}
void solve(){
memset(st, 0, sizeof(st));
for(int i = 1; i <= n; i++){
int x;
cin >> x;
update(1, 1, n, i, x);
}
for(int _ = 0; _ < q; _++){
int _t, u, v;
cin >> _t >> u >> v;
if(_t == 1){
update(1, 1, n, u, v);
}
else{
cout << (((v - u) & 1) ? 0 : get(u & 1, 1, 1, n, u, v)) << "\n";
}
}
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> q;
if(n <= 5000){
sub123::solve();
}
else{
sub45::solve();
}
}
Compilation message (stderr)
xoranges.cpp: In function 'int main()':
xoranges.cpp:83:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
83 | freopen(taskname".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |