Submission #123517

#TimeUsernameProblemLanguageResultExecution timeMemory
123517nxteruDancing Elephants (IOI11_elephants)C++14
Compilation error
0 ms0 KiB
#include "elephants.h" #include <bits/stdc++.h> using namespace std; #define B 350 int MAX_N; int n,k,bs[MAX_N/B+2],p[MAX_N],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]); } 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 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; }

Compilation message (stderr)

elephants.cpp:6:21: error: array bound is not an integer constant before ']' token
 int n,k,bs[MAX_N/B+2],p[MAX_N],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:30: error: array bound is not an integer constant before ']' token
 int n,k,bs[MAX_N/B+2],p[MAX_N],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:40: error: array bound is not an integer constant before ']' token
 int n,k,bs[MAX_N/B+2],p[MAX_N],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:60: error: array bound is not an integer constant before ']' token
 int n,k,bs[MAX_N/B+2],p[MAX_N],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:81: error: array bound is not an integer constant before ']' token
 int n,k,bs[MAX_N/B+2],p[MAX_N],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:102: error: array bound is not an integer constant before ']' token
 int n,k,bs[MAX_N/B+2],p[MAX_N],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:22:22: error: 'pl' was not declared in this scope
  for(int i=0;i<n;i++)pl[i]=p[i];
                      ^~
elephants.cpp:22:22: note: suggested alternative: 'l'
  for(int i=0;i<n;i++)pl[i]=p[i];
                      ^~
                      l
elephants.cpp:22:28: error: 'p' was not declared in this scope
  for(int i=0;i<n;i++)pl[i]=p[i];
                            ^
elephants.cpp:23:7: error: 'pl' was not declared in this scope
  sort(pl,pl+n);
       ^~
elephants.cpp:23:7: note: suggested alternative: 'l'
  sort(pl,pl+n);
       ^~
       l
elephants.cpp:24:2: error: 'bs' was not declared in this scope
  bs[0]=0;
  ^~
elephants.cpp:24:2: note: suggested alternative: 'abs'
  bs[0]=0;
  ^~
  abs
elephants.cpp:31:3: error: 'el' was not declared in this scope
   el[k][bs[k]]=pl[i];
   ^~
elephants.cpp:31:3: note: suggested alternative: 'l'
   el[k][bs[k]]=pl[i];
   ^~
   l
elephants.cpp:34: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:34: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:34: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:34: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 'void init(int, int, int*)':
elephants.cpp:39:22: error: 'p' was not declared in this scope
  for(int i=0;i<n;i++)p[i]=X[i];
                      ^
elephants.cpp: In function 'int update(int, int)':
elephants.cpp:43:13: error: 'p' was not declared in this scope
  int a=-1,b=p[t];
             ^
elephants.cpp:44: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:44: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:44: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:44: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:46:16: error: 'bs' was not declared in this scope
  for(int i=0;i<bs[a]-1;i++){
                ^~
elephants.cpp:46:16: note: suggested alternative: 'b'
  for(int i=0;i<bs[a]-1;i++){
                ^~
                b
elephants.cpp:47:6: error: 'el' was not declared in this scope
   if(el[a][i]==b){
      ^~
elephants.cpp:47:6: note: suggested alternative: 'l'
   if(el[a][i]==b){
      ^~
      l
elephants.cpp:52:2: error: 'bs' was not declared in this scope
  bs[a]--;
  ^~
elephants.cpp:52:2: note: suggested alternative: 'b'
  bs[a]--;
  ^~
  b
elephants.cpp:53:9: error: 'el' was not declared in this scope
  Bini(a,el[a],bs[a],ds[a],sz[a]);
         ^~
elephants.cpp:53:9: note: suggested alternative: 'l'
  Bini(a,el[a],bs[a],ds[a],sz[a]);
         ^~
         l
elephants.cpp:53:21: error: 'ds' was not declared in this scope
  Bini(a,el[a],bs[a],ds[a],sz[a]);
                     ^~
elephants.cpp:53:27: error: 'sz' was not declared in this scope
  Bini(a,el[a],bs[a],ds[a],sz[a]);
                           ^~