#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;
const ll INF = 2000000000000000007, DIM = 200007, DIM2 = 107, MAXN = 100007, MOD = 998244353 ;
ll tt, mid, res,f, q, a[DIM], b[DIM], d[DIM], used[DIM], dp[DIM], y, type, ptr, root, cnt, sum, pos, h, p, sx,sy, id, testcase, curans, nn, split, n, m, x, k1, k2, changecnt,k,l,r,v,u, l1,r1,l2,r2;
bool flag, flag2;
char c;
struct segTree {
ll t[4*DIM];
void build(int v, int vl, int vr) {
if(vl==vr){
t[v]=a[vl];
return;
}
int vm=(vl+vr)/2;
build(v*2+1,vl,vm);
build(v*2+2,vm+1,vr);
t[v]=t[v*2+1]^t[v*2+2];
}
ll query(int v, int vl, int vr, int l, int r){
if(vl > r || vr < l)return 0;
if(vl >=l &&vr<=r) return t[v];
int vm=(vl+vr)/2;
return query(v*2+1,vl,vm,l,r)^query(v*2+2,vm+1,vr,l,r);
}
void modify(int v, int vl, int vr, int pos, ll x) {
if(vl==vr) {
t[v]=x;
return;
}
int vm=(vl+vr)/2;
if(pos<=vm)
modify(v*2+1,vl,vm,pos,x);
else modify(v*2+2,vm+1,vr,pos,x);
t[v]=t[v*2+1]^t[v*2+2];
}
};
segTree t[3];
void solve() {
cin>>n>>q;
for(int i=1;i<=n;i++) {cin>>a[i];b[i]=a[i];}
for(int i=1;i<=n;i++){
if(i%2==1)a[i]=b[i];
else a[i]=0;
}
t[1].build(0,1,n);
for(int i=1;i<=n;i++){
if(i%2==0)a[i]=b[i];
else a[i]=0;
}
t[2].build(0,1,n);
for(int i=1;i<=q;i++){
cin>>type>>l>>r;
if(type==2) {
if((r-l+1)%2==0)cout<<"0\n";
else {
if(l%2==1)cout<<t[1].query(0,1,n,l,r)<<'\n';
else cout<<t[2].query(0,1,n,l,r)<<'\n';
}
} else {
if(l%2==1)t[1].modify(0,1,n,l,r);
else t[2].modify(0,1,n,l,r);
}
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
tt=1;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
//cin>>tt;
while(tt--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
260 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
260 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
3 ms |
724 KB |
Output is correct |
14 |
Correct |
3 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
12824 KB |
Output is correct |
2 |
Correct |
153 ms |
12896 KB |
Output is correct |
3 |
Correct |
114 ms |
12832 KB |
Output is correct |
4 |
Correct |
101 ms |
12836 KB |
Output is correct |
5 |
Correct |
108 ms |
12948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
260 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
3 ms |
724 KB |
Output is correct |
14 |
Correct |
3 ms |
724 KB |
Output is correct |
15 |
Correct |
120 ms |
12824 KB |
Output is correct |
16 |
Correct |
153 ms |
12896 KB |
Output is correct |
17 |
Correct |
114 ms |
12832 KB |
Output is correct |
18 |
Correct |
101 ms |
12836 KB |
Output is correct |
19 |
Correct |
108 ms |
12948 KB |
Output is correct |
20 |
Correct |
132 ms |
12212 KB |
Output is correct |
21 |
Correct |
118 ms |
12176 KB |
Output is correct |
22 |
Correct |
109 ms |
12228 KB |
Output is correct |
23 |
Correct |
101 ms |
12692 KB |
Output is correct |
24 |
Correct |
98 ms |
12748 KB |
Output is correct |