제출 #57418

#제출 시각아이디문제언어결과실행 시간메모리
57418fefe휴가 (IOI14_holiday)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define MAX_N 100005 using namespace std; typedef long long LL; struct pst{ LL cnt,sum; pst *l,*r; pst(LL cnt,LL sum,pst *l,pst *r):cnt(cnt),sum(sum),l(l),r(r){} pst *update(LL idx,LL p){ if(idx<0) return new pst(cnt+1,sum+p,NULL,NULL); if(p>>idx&1) return new pst(cnt+1,sum+p,l,r->update(idx-1,p)); return new pst(cnt+1,sum+p,l->update(idx-1,p),r); } }*tree[MAX_N]; LL n,st,d,dx,ans; LL s_t[MAX_N],s_tt[MAX_N],e_t[MAX_N],e_tt[MAX_N]; LL get_sum(LL idx,pst *l,pst *r,LL x,LL p){ if(idx<0) return min(x,r->cnt-l->cnt)*p; LL y=r->l->cnt-l->l->cnt,z=r->r->cnt-l->r->cnt; if(r->cnt-l->cnt==p) return r->sum-l->sum; if(y<x && z!=0) return get_sum(idx-1,l->r,r->r,x-y,p|(1LL<<idx))+r->l->sum-l->l->sum; return get_sum(idx-1,l->l,r->l,x,p); } void dnc(LL s,LL e,LL l,LL r,bool p,bool q){ LL mid=(l+r)>>1; LL i,di=s,dix=-1; LL x,y; LL a,b; if(l>r) return; for(i=s;i<=e;i++){ y=q?2*abs(st-i):abs(st-i); if(mid-y<0) continue; x=get_sum(29,tree[(p?st:i-1)],tree[(p?i:st-1)],mid-y,0); if(x>dix){ dix=x; di=i; } } if(q){ if(p) e_tt[mid]=max(e_tt[mid],dix); else s_tt[mid]=max(s_tt[mid],dix); }else{ if(p) e_t[mid]=max(e_t[mid],dix); else s_t[mid]=max(s_t[mid],dix); } dnc(s,di,l,mid-1,p,q); dnc(di,e,mid+1,r,p,q); } int main(){ LL i,x; scanf("%lld %lld %lld",&n,&st,&d); tree[0]=new pst(0,0,NULL,NULL);tree[0]->l=tree[0]->r=tree[0]; for(i=1;i<=n;i++){ scanf("%lld",&x); tree[i]=tree[i-1]->update(29,x); if(i==st) dx=x; } dnc(1,st-1,0,d,false,true); dnc(st+1,n,0,d,true,true); dnc(1,st-1,0,d,false,false); dnc(st+1,n,0,d,true,false); ans=max(max(s_t[d-1]+dx,s_t[d]),max(e_t[d-1]+dx,e_t[d])); for(i=0;i<=d;i++){ ans=max(ans,max(s_t[i]+e_tt[d-i],s_tt[i]+e_t[d-i])); if(i!=d) ans=max(ans,max(s_t[i]+e_tt[d-i-1],s_tt[i]+e_t[d-i-1])+dx); } printf("%lld\n",ans); return 0; }

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

holiday.cpp: In function 'void dnc(LL, LL, LL, LL, bool, bool)':
holiday.cpp:28:5: warning: unused variable 'a' [-Wunused-variable]
  LL a,b;
     ^
holiday.cpp:28:7: warning: unused variable 'b' [-Wunused-variable]
  LL a,b;
       ^
holiday.cpp: In function 'int main()':
holiday.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&n,&st,&d);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
holiday.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&x);
   ~~~~~^~~~~~~~~~~
grader.cpp: In function 'int main()':
grader.cpp:7:12: warning: variable 'n_s' set but not used [-Wunused-but-set-variable]
     int i, n_s;
            ^~~
/tmp/ccks4BPb.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccAR4947.o:holiday.cpp:(.text.startup+0x0): first defined here
/tmp/ccks4BPb.o: In function `main':
grader.cpp:(.text.startup+0x7a): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status