#include <bits/stdc++.h>
#define pb push_back
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0)
#define endl "\n"
#define all(v) v.begin(),v.end()
#define int long long
using namespace std;
const int INF = 1e17, MOD = 1e9 + 7, N = 6e5 + 5, MOD2 = 998244353;
int fpow(int a, int b){ // returns a to the power of b %MOD
if(b == 0) return 1;
if(b == 1) return a;
int x = fpow(a,b/2)%MOD;
if(b%2) return ((x*x)%MOD*a)%MOD;
else return (x*x)%MOD;
}
int32_t main(){
fastio;
int n, q;
cin>>n>>q;
vector<int> a(n + 1), oddxr(n + 1), evenxr(n + 1);
for(int i = 1; i <= n; i++){
cin>>a[i];
if(i == 1) oddxr[i] = a[i];
else if(i == 2) evenxr[i] = a[i];
else if(i&1) oddxr[i] = a[i]^oddxr[i-2];
else evenxr[i] = a[i]^evenxr[i-2];
}
while(q--){
int type;
cin>>type;
if(type == 1){
int ind, x;
cin>>ind>>x;
a[ind] = x;
}
else{ // type == 2
int l, u;
cin>>l>>u;
if((u - l + 1)&1){
int res;
if(l == 1) res = oddxr[u];
else if(l == 2) res = evenxr[u];
else if(l&1) res = oddxr[u]^oddxr[l-2];
else res = evenxr[u]^evenxr[l-2];
cout<<res<<endl;
}
else{
cout<<0<<endl;
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
7112 KB |
Output is correct |
2 |
Correct |
85 ms |
10836 KB |
Output is correct |
3 |
Correct |
81 ms |
10872 KB |
Output is correct |
4 |
Correct |
74 ms |
10516 KB |
Output is correct |
5 |
Correct |
75 ms |
10508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |