제출 #31151

#제출 시각아이디문제언어결과실행 시간메모리
31151skykhs3마상시합 토너먼트 (IOI12_tournament)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define MAXN 100005 using namespace std; int K[MAXN],S[MAXN],E[MAXN],N,C,R,nn,sum[MAXN],v,mx=-1; int seg[MAXN*4],mxseg[MAXN*4]; int query1(int lef,int rig,int lev,int x){ if(x==0) return -1; if(lef==rig) return lef; else{ int mid=lef+rig>>1; if(seg[lev*2]>=x) return query1(lef,mid,lev*2,x); else return query1(mid+1,rig,lev*2+1,x-seg[lev*2]); } } void query2(int lef,int rig,int lev,int s,int e){ if(rig<s || e<lef) return; if(s<=lef && rig<=e) seg[lev]=0; else{ int mid=(lef+rig)/2; query2(lef,mid,lev*2,s,e); query2(mid+1,rig,lev*2+1,s,e); seg[lev]=seg[lev*2]+seg[lev*2+1]; } } int query3(int lef,int rig,int lev,int s,int e){ if(rig<s || e<lef) return -1; if(s<=lef && rig<=e) return mxseg[lev]; else{ int mid=lef+rig>>1; return max(query3(lef,mid,lev*2,s,e),query3(mid+1,rig,lev*2+1,s,e)); } } int main() { scanf("%d%d%d",&N,&C,&R); for(int i=0;i<N-1;i++) scanf("%d",&K[i]); for(int i=0;i<C;i++) scanf("%d%d",&S[i],&E[i]); for(nn=1;nn<N;nn*=2); for(int i=0;i<N;i++) seg[i+nn]=1,mxseg[i+nn]=K[i]; for(int i=nn-1;i>=1;i--) seg[i]=seg[i*2]+seg[i*2+1],mxseg[i]=max(mxseg[i*2],mxseg[i*2+1]); for(int i=0;i<C;i++){ int p2=query1(0,nn-1,1,E[i]+1),p1=query1(0,nn-1,1,S[i])+1; query2(0,nn-1,1,p1,p2-1); if(query3(0,nn-1,1,p1,p2-1)<=R) sum[p1]++,sum[p2+1]--; } int st=0; for(int i=0;i<N;i++){ st+=sum[i]; if(mx<st){ mx=st; v=i; } } printf("%d",v); }

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

tournament.cpp: In function 'int query1(int, int, int, int)':
tournament.cpp:10:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid=lef+rig>>1;
                    ^
tournament.cpp: In function 'int query3(int, int, int, int, int)':
tournament.cpp:29:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid=lef+rig>>1;
                    ^
tournament.cpp: In function 'int main()':
tournament.cpp:35:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&N,&C,&R);
                             ^
tournament.cpp:36:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<N-1;i++) scanf("%d",&K[i]);
                                             ^
tournament.cpp:37:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<C;i++) scanf("%d%d",&S[i],&E[i]);
                                                   ^
/tmp/ccG3jFqN.o: In function `main':
tournament.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccmNodXA.o:grader.cpp:(.text.startup+0x0): first defined here
/tmp/ccmNodXA.o: In function `main':
grader.cpp:(.text.startup+0x104): undefined reference to `GetBestPosition(int, int, int, int*, int*, int*)'
collect2: error: ld returned 1 exit status