이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll int
#define ld double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 2e5 + 9;
const ll mod = 1e9 + 7;
ll n,q,a[N];
ll st[4*N][2];
void upd(ll id,ll type,ll l,ll r,ll u,ll val){
if (u < l||r < u) return;
if (l == r){
st[id][type] ^= val; return;
}
ll mid = (l + r)/2;
upd(id*2,type,l,mid,u,val);
upd(id*2 + 1,type,mid + 1,r,u,val);
st[id][type] = st[id*2][type] ^ st[id*2 + 1][type];
}
ll Get(ll id,ll type,ll l,ll r,ll u,ll v){
if (v < l||r < u) return 0;
if (u <= l&&r <= v) return st[id][type];
ll mid = (l + r)/2;
return Get(id*2,type,l,mid,u,v) ^ Get(id*2 + 1,type,mid + 1,r,u,v);
}
int main(){
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define task "test"
if (fopen(task".inp","r")){
freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
}
cin>>n>>q;
for (ll i = 1;i <= n;i++){
cin>>a[i];
upd(1,i%2,1,n,i,a[i]);
}
while(q--){
ll type; cin>>type;
if (type == 1){
ll pos,val; cin>>pos>>val;
upd(1,pos%2,1,n,pos,a[pos]);
a[pos] = val;
upd(1,pos%2,1,n,pos,a[pos]);
}
else{
ll l,r; cin>>l>>r;
if ((r - l + 1)%2){
cout<<Get(1,l%2,1,n,l,r)<<"\n";
}
else cout<<0<<"\n";
}
}
}
/* be confident */
컴파일 시 표준 에러 (stderr) 메시지
xoranges.cpp: In function 'int main()':
xoranges.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | freopen(task".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... |