이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
const int mxn=2e5+5;
ll arr[mxn],tree[4*mxn];
void build_tree(int id,int l,int r){
if(l==r){
tree[id]=arr[l];
return;
}
int m=(l+r)/2;
build_tree(2*id,l,m);
build_tree(2*id+1,m+1,r);
tree[id]=tree[2*id]^tree[2*id+1];
}
ll find_xor(int id,int l,int r,int i1,int i2){
if(i1>i2){
return 0;
}
if(l==i1&&r==i2){
return tree[id];
}
int m=(l+r)/2;
ll a=find_xor(2*id,l,m,i1,min(m,i2));
ll b=find_xor(2*id+1,m+1,r,max(i1,m+1),i2);
return a^b;
}
void update_tree(int id,int l,int r,int ind,int value){
if(l==r){
tree[id]=value;
return;
}
int m=(l+r)/2;
if(ind<=m) update_tree(2*id,l,m,ind,value);
else update_tree(2*id+1,m+1,r,ind,value);
tree[id]=tree[2*id]^tree[2*id+1];
}
int main(){
int n,m,a,b,c;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
scanf("%lld",&arr[i]);
}
build_tree(1,0,n-1);
while(m--){
scanf("%d %d %d",&a,&b,&c);
if(a==2){
b--;
c--;
ll sum=0;
for(int i=b;i<=c;i++){
for(int j=i;j<=c;j++){
sum^=find_xor(1,0,n-1,i,j);
}
}
printf("%lld\n",sum);
}
else if(a==1){
b--;
update_tree(1,0,n-1,b,c);
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
xoranges.cpp: In function 'int main()':
xoranges.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
41 | scanf("%d %d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~
xoranges.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
43 | scanf("%lld",&arr[i]);
| ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
47 | scanf("%d %d %d",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~| # | 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... |