제출 #240338

#제출 시각아이디문제언어결과실행 시간메모리
240338blacktulipXORanges (eJOI19_xoranges)C++17
100 / 100
204 ms11256 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define mp make_pair #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo MAX = -1000000000000000000; const lo MIN = 1000000000000000000; const lo inf = 1000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 500005; const lo mod = 1000000007; int n,m,b[li],a[li],k,flag,t,tree[li*4],tree1[4*li],x,y,z; int cev; string s; vector<int> v; inline void build(int node,int start,int end){ if(start>end)return ; if(start==end && start%2==1)return ; if(start==end && start%2==0){tree[node]=a[start];return ;} build(node*2,start,mid); build(node*2+1,mid+1,end); tree[node]=tree[node*2]^tree[node*2+1]; } inline void update(int node,int start,int end,int l,int r,int val){ if(start>end || start>r || end<l)return ; if(start>=l && end<=r){tree[node]=val;return ;} update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val); tree[node]=tree[node*2]^tree[node*2+1]; } inline int query(int node,int start,int end,int l,int r){ if(start>end || start>r || end<l)return 0; if(start>=l && end<=r){return tree[node];} return query(node*2,start,mid,l,r)^query(node*2+1,mid+1,end,l,r); } inline void build1(int node,int start,int end){ if(start>end)return ; if(start==end && start%2==0)return ; if(start==end && start%2==1){tree1[node]=a[start];return ;} build1(node*2,start,mid); build1(node*2+1,mid+1,end); tree1[node]=tree1[node*2]^tree1[node*2+1]; } inline void update1(int node,int start,int end,int l,int r,int val){ if(start>end || start>r || end<l)return ; if(start>=l && end<=r){tree1[node]=val;return ;} update1(node*2,start,mid,l,r,val),update1(node*2+1,mid+1,end,l,r,val); tree1[node]=tree1[node*2]^tree1[node*2+1]; } inline int query1(int node,int start,int end,int l,int r){ if(start>end || start>r || end<l)return 0; if(start>=l && end<=r){return tree1[node];} return query1(node*2,start,mid,l,r)^query1(node*2+1,mid+1,end,l,r); } int main(void){ scanf("%d %d",&n,&t); FOR{ scanf("%d",&a[i]); } build(1,1,n); build1(1,1,n); while(t--){ scanf("%d %d %d",&x,&y,&z); if(x==1){ if(y%2==1)update1(1,1,n,y,y,z); else update(1,1,n,y,y,z); continue; } int at=z-y+1; if(at%2==0){printf("0\n");continue;} if(y%2==0){ printf("%d\n",query(1,1,n,y,z)); } else{ printf("%d\n",query1(1,1,n,y,z)); } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

xoranges.cpp: In function 'int main()':
xoranges.cpp:75:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&t);
  ~~~~~^~~~~~~~~~~~~~~
xoranges.cpp:77:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
xoranges.cpp:82:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&x,&y,&z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...