#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector <ll> vi;
typedef pair<ll,ll> pll;
#define mp make_pair
#define pb push_back
#define N ((ll)(5))
#define INF ((ll)1e18+18)
#define bismillah {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
ll n,m;
ll st[4*N];
ll st2[4*N];
ll v[N];
void build1(ll l , ll r , ll i){
if (l==r ){
st[i] = v[l];
return;
}
ll tm = (l + r) >> 1;
build1(l, tm, 2*i);
build1(tm+1, r, 2*i+1);
st[i] = st[2*i] ^ st[2*i+1];
}
void build2(ll l , ll r , ll i){
if (l==r ){
// that means
// if index is even st value is 0
st2[i] = v[l] * (l%2);
return;
}
ll tm = (l + r) >> 1;
build2(l, tm, 2*i);
build2(tm+1, r, 2*i+1);
st2[i] = st2[2*i] ^ st2[2*i+1];
}
void update(ll l , ll r , ll pos , ll i , ll val){
if (pos > r or pos < l)return;
if (l == r){st[i] = val;return;}
ll tm = (l+r)>>1;
if (pos <= tm) update(l, tm, pos, 2*i, val);
else update(tm+1,r,pos , 2*i+1, val);
st[i] = st[2*i] ^ st[2*i+1];
}
void update2(ll l , ll r , ll pos , ll i , ll val){
if (pos > r or pos < l)return;
if (l == r){st2[i] = val * (l%2);return;}
ll tm = (l+r)>>1;
if (pos <= tm) update2(l, tm, pos, 2*i, val);
else update2(tm+1,r,pos , 2*i+1, val);
st2[i] = st2[2*i] ^ st2[2*i+1];
}
ll query(ll l , ll r , ll ql , ll qr , ll i){
if (ql > r or qr < l)return 0;
if (ql<=l and r <= qr) return st[i];
ll tm = (l+r)>>1;
return query(l, tm,ql, qr, 2*i) ^ query(tm+1, r, ql, qr, 2*i+1);
}
ll query2(ll l , ll r , ll ql , ll qr , ll i){
if (ql > r or qr < l)return 0;
if (ql<=l and r <= qr) return st2[i];
ll tm = (l+r)>>1;
return query2(l, tm,ql, qr, 2*i) ^ query2(tm+1, r, ql, qr, 2*i+1);
}
int main(){
bismillah
cin >> n >> m;
for (ll i = 0 ; i < n ; i ++){
cin >> v[i];
}
build1(0, n-1, 1);
build2(0, n-1, 1);
for (ll j = 0; j < m ; j++){
ll t , l , r;
cin >> t >> l >> r;
if (t == 1){
update(0, n-1, l-1, 1, r);
update2(0, n-1, l-1, 1, r);
}else {
if ((r-l+1)%2 == 0){
cout << 0 << endl;
}else {
ll q1 = query(0, n-1, l-1, r-1, 1);
ll q2 = query2(0, n-1, l-1, r-1, 1);
if (l%2==0){
cout << q2 << endl;
}else {
cout << (q2 ^ q1) << endl;
}
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |