제출 #288414

#제출 시각아이디문제언어결과실행 시간메모리
288414topovikXORanges (eJOI19_xoranges)C++14
0 / 100
173 ms6264 KiB
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define INF 1000000000 using namespace std; typedef long long ll; typedef long double ld; const ll oo = 1e12; const int N = 1e6; int a[N]; int val[N][2]; int n,q; void Build(int l, int r, int posx, int posy) { if (l==r) { if ((l*2+posy-2)<n) val[posx][posy]=a[l*2+posy-2]; return ; } int mdl=(l+r)>>1; Build(l,mdl,posx*2,posy); Build(mdl+1,r,posx*2+1,posy); val[posx][posy]=val[posx*2][posy]^val[posx*2+1][posy]; } inline void Upd(int l, int r, int nom, int zn,int posx, int posy) { if (l>nom || r<nom) return ; if (l==r) {val[posx][posy]=zn;return;} int mdl=(l+r)>>1; Upd(l,mdl,nom,zn,posx*2,posy); Upd(mdl+1,r,nom,zn,posx*2+1,posy); val[posx][posy]=val[posx*2][posy]^val[posx*2+1][posy]; } inline int Sum(int l, int r, int l1, int r1, int posx, int posy) { if (l1>r1) return 0; if (l1==l && r1==r) return val[posx][posy]; int mdl=(l+r)>>1; return Sum(l,mdl,l1,min(mdl,r1),posx<<1,posy)^Sum(mdl+1,r,max(mdl+1,l1),r1,posx<<1+1,posy); } int main() { cin>>n>>q; for (int i=0; i<n; i++) cin>>a[i]; Build(1,(n+1)>>1,1,0); Build(1,n>>1,1,1); while (q>0) { q--; int nom,x,y; cin>>nom>>x>>y; if (nom==1) Upd(1,(n+1)>>1,(x+1)/2,y,1,(x+1)&1); else { if (!((y-x+1)&1)) cout<<0<<endl; else cout<<Sum(1,(n+1)/2,(x+1)/2,(y+1)/2,1,(x+1)&1)<<endl; } } }

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

xoranges.cpp: In function 'int Sum(int, int, int, int, int, int)':
xoranges.cpp:48:87: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   48 |     return Sum(l,mdl,l1,min(mdl,r1),posx<<1,posy)^Sum(mdl+1,r,max(mdl+1,l1),r1,posx<<1+1,posy);
      |                                                                                      ~^~
#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...