이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define loop(i,n) for (ll i = 0; i < n; i++)
#define ll long long
#define INF 1e9+5
#define MAXN 200007
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> pii;
ll arr[MAXN];
ll seg[4*MAXN][2];
void recalculate(ll int node){
seg[node][0]=seg[2*node+1][0]^seg[2*node+2][0];
seg[node][1]=seg[2*node+1][1]^seg[2*node+2][1];
}
void build(ll node, ll left, ll right){
if(left==right){
if(left%2==0){seg[node][0]=arr[left]; seg[node][1]=0; }
else{ seg[node][1]=arr[left]; seg[node][0]=0;}
}else{
ll middle=(left+right)/2;
build(2*node+1,left,middle);
build(2*node+2,middle+1,right);
recalculate(node);
}
}
void update(ll node, ll left, ll right, ll x, ll y){
if(left==right){
if(left%2==0){seg[node][0]=y; seg[node][1]=0; }
else{ seg[node][1]=y; seg[node][0]=0;}
}else{
ll middle=(left+right)/2;
if(x<=middle){
update(2*node+1,left,middle,x,y);
}else{
update(2*node+2,middle+1,right,x,y);
}
recalculate(node);
}
}
ll bruh;
ll querie(ll node, ll left, ll right, ll a, ll b){
if(a<=left&&b>=right)return seg[node][bruh];
ll middle=(left+right)/2,ans=0;
if(a<=middle)ans^=querie(2*node+1,left,middle,a,b);
if(b>=middle+1)ans^=querie(2*node+2,middle+1,right,a,b);
return ans;
}
int main(){
ll n,q,type,i,j,l,r;
cin>>n>>q;
loop(i,n){
scanf("%lld",&arr[i+1]);
}
build(0,1,n);
while(q--){
scanf("%lld",&type);
if(type==1){
scanf("%lld%lld",&i,&j);
arr[i]=j;
update(0,1,n,i,j);
}else{
scanf("%lld%lld",&l,&r);
bruh=l%2;
printf("%lld\n",querie(0,1,n,l,r));
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
xoranges.cpp: In function 'int main()':
xoranges.cpp:89:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&arr[i+1]);
~~~~~^~~~~~~~~~~~~~~~~~
xoranges.cpp:96:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&type);
~~~~~^~~~~~~~~~~~~~
xoranges.cpp:100:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&i,&j);
~~~~~^~~~~~~~~~~~~~~~~~
xoranges.cpp:107:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&l,&r);
~~~~~^~~~~~~~~~~~~~~~~~
# | 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... |