제출 #123519

#제출 시각아이디문제언어결과실행 시간메모리
123519nxteru코끼리 (Dancing Elephants) (IOI11_elephants)C++14
컴파일 에러
0 ms0 KiB
#include "elephants.h" #include <bits/stdc++.h> using namespace std; #define B 350 void ALLini(void); int MAX_N,n,p[150005],l; void init(int N, int L, int X[]){ n=N,l=L; MAX_N=n; for(int i=0;i<n;i++)p[i]=X[i]; ALLini(); } int k,bs[MAX_N/B+2],pl[MAX_N],l,cnt,ds[MAX_N/B+2][B*3+1],sz[MAX_N/B+2][B*3+1],el[MAX_N/B+2][B*3+1]; void Bini(int x,int *xel,int xbs,int *xds,int *xsz){ sort(xel,xel+xbs); int r=xbs; for(int i=xbs-1;i>=0;i--){ while(r-1>=0&&xel[i]+l<xel[r-1])r--; if(r==xbs){ xds[i]=xel[i]+l; xsz[i]=1; }else{ xds[i]=xds[r]; xsz[i]=xsz[r]+1; } } } void ALLini(void){ for(int i=0;i<n;i++)pl[i]=p[i]; sort(pl,pl+n); bs[0]=0; k=0; for(int i=0;i<n;i++){ if(bs[k]>=B){ k++; bs[k]=0; } el[k][bs[k]]=pl[i]; bs[k]++; } for(int i=0;i<=k;i++)Bini(i,el[i],bs[i],ds[i],sz[i]); } int update(int t, int y){ int a=-1,b=p[t]; while(a+1<=k&&bs[a+1]==0||(bs[a+1]>=1&&el[a+1][0]<=b))a++; if(a==-1)a=0; for(int i=0;i<bs[a]-1;i++){ if(el[a][i]==b){ el[a][i]=el[a][bs[a]-1]; break; } } bs[a]--; Bini(a,el[a],bs[a],ds[a],sz[a]); p[t]=y; a=-1; while(a+1<=k&&bs[a+1]==0||(bs[a+1]>=1&&el[a+1][0]<=y))a++; if(a==-1)a=0; el[a][bs[a]]=y; bs[a]++; Bini(a,el[a],bs[a],ds[a],sz[a]); int ans=0; a=0,b=-1; for(;a<=k;a++){ if(bs[a]==0)continue; int c=upper_bound(el[a],el[a]+bs[a],b)-el[a]; if(c==bs[a])continue; ans+=sz[a][c]; b=ds[a][c]; } cnt++; if(cnt>=B/2){ cnt=0; ALLini(); } return ans; }

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

elephants.cpp:13:19: error: array bound is not an integer constant before ']' token
 int k,bs[MAX_N/B+2],pl[MAX_N],l,cnt,ds[MAX_N/B+2][B*3+1],sz[MAX_N/B+2][B*3+1],el[MAX_N/B+2][B*3+1];
                   ^
elephants.cpp:13:29: error: array bound is not an integer constant before ']' token
 int k,bs[MAX_N/B+2],pl[MAX_N],l,cnt,ds[MAX_N/B+2][B*3+1],sz[MAX_N/B+2][B*3+1],el[MAX_N/B+2][B*3+1];
                             ^
elephants.cpp:13:31: error: redefinition of 'int l'
 int k,bs[MAX_N/B+2],pl[MAX_N],l,cnt,ds[MAX_N/B+2][B*3+1],sz[MAX_N/B+2][B*3+1],el[MAX_N/B+2][B*3+1];
                               ^
elephants.cpp:6:23: note: 'int l' previously declared here
 int MAX_N,n,p[150005],l;
                       ^
elephants.cpp:13:49: error: array bound is not an integer constant before ']' token
 int k,bs[MAX_N/B+2],pl[MAX_N],l,cnt,ds[MAX_N/B+2][B*3+1],sz[MAX_N/B+2][B*3+1],el[MAX_N/B+2][B*3+1];
                                                 ^
elephants.cpp:13:70: error: array bound is not an integer constant before ']' token
 int k,bs[MAX_N/B+2],pl[MAX_N],l,cnt,ds[MAX_N/B+2][B*3+1],sz[MAX_N/B+2][B*3+1],el[MAX_N/B+2][B*3+1];
                                                                      ^
elephants.cpp:13:91: error: array bound is not an integer constant before ']' token
 int k,bs[MAX_N/B+2],pl[MAX_N],l,cnt,ds[MAX_N/B+2][B*3+1],sz[MAX_N/B+2][B*3+1],el[MAX_N/B+2][B*3+1];
                                                                                           ^
elephants.cpp: In function 'void ALLini()':
elephants.cpp:29:22: error: 'pl' was not declared in this scope
  for(int i=0;i<n;i++)pl[i]=p[i];
                      ^~
elephants.cpp:29:22: note: suggested alternative: 'l'
  for(int i=0;i<n;i++)pl[i]=p[i];
                      ^~
                      l
elephants.cpp:30:7: error: 'pl' was not declared in this scope
  sort(pl,pl+n);
       ^~
elephants.cpp:30:7: note: suggested alternative: 'l'
  sort(pl,pl+n);
       ^~
       l
elephants.cpp:31:2: error: 'bs' was not declared in this scope
  bs[0]=0;
  ^~
elephants.cpp:31:2: note: suggested alternative: 'abs'
  bs[0]=0;
  ^~
  abs
elephants.cpp:38:3: error: 'el' was not declared in this scope
   el[k][bs[k]]=pl[i];
   ^~
elephants.cpp:38:3: note: suggested alternative: 'l'
   el[k][bs[k]]=pl[i];
   ^~
   l
elephants.cpp:41:30: error: 'el' was not declared in this scope
  for(int i=0;i<=k;i++)Bini(i,el[i],bs[i],ds[i],sz[i]);
                              ^~
elephants.cpp:41:30: note: suggested alternative: 'l'
  for(int i=0;i<=k;i++)Bini(i,el[i],bs[i],ds[i],sz[i]);
                              ^~
                              l
elephants.cpp:41:42: error: 'ds' was not declared in this scope
  for(int i=0;i<=k;i++)Bini(i,el[i],bs[i],ds[i],sz[i]);
                                          ^~
elephants.cpp:41:48: error: 'sz' was not declared in this scope
  for(int i=0;i<=k;i++)Bini(i,el[i],bs[i],ds[i],sz[i]);
                                                ^~
elephants.cpp: In function 'int update(int, int)':
elephants.cpp:45:16: error: 'bs' was not declared in this scope
  while(a+1<=k&&bs[a+1]==0||(bs[a+1]>=1&&el[a+1][0]<=b))a++;
                ^~
elephants.cpp:45:16: note: suggested alternative: 'b'
  while(a+1<=k&&bs[a+1]==0||(bs[a+1]>=1&&el[a+1][0]<=b))a++;
                ^~
                b
elephants.cpp:45:41: error: 'el' was not declared in this scope
  while(a+1<=k&&bs[a+1]==0||(bs[a+1]>=1&&el[a+1][0]<=b))a++;
                                         ^~
elephants.cpp:45:41: note: suggested alternative: 'l'
  while(a+1<=k&&bs[a+1]==0||(bs[a+1]>=1&&el[a+1][0]<=b))a++;
                                         ^~
                                         l
elephants.cpp:47:16: error: 'bs' was not declared in this scope
  for(int i=0;i<bs[a]-1;i++){
                ^~
elephants.cpp:47:16: note: suggested alternative: 'b'
  for(int i=0;i<bs[a]-1;i++){
                ^~
                b
elephants.cpp:48:6: error: 'el' was not declared in this scope
   if(el[a][i]==b){
      ^~
elephants.cpp:48:6: note: suggested alternative: 'l'
   if(el[a][i]==b){
      ^~
      l
elephants.cpp:53:2: error: 'bs' was not declared in this scope
  bs[a]--;
  ^~
elephants.cpp:53:2: note: suggested alternative: 'b'
  bs[a]--;
  ^~
  b
elephants.cpp:54:9: error: 'el' was not declared in this scope
  Bini(a,el[a],bs[a],ds[a],sz[a]);
         ^~
elephants.cpp:54:9: note: suggested alternative: 'l'
  Bini(a,el[a],bs[a],ds[a],sz[a]);
         ^~
         l
elephants.cpp:54:21: error: 'ds' was not declared in this scope
  Bini(a,el[a],bs[a],ds[a],sz[a]);
                     ^~
elephants.cpp:54:27: error: 'sz' was not declared in this scope
  Bini(a,el[a],bs[a],ds[a],sz[a]);
                           ^~