Submission #1188547

#TimeUsernameProblemLanguageResultExecution timeMemory
1188547Ak_16Mechanical Doll (IOI18_doll)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include "doll.h" using namespace std; int bad[1000000]; int po[20]; int n; int bg = 1000000; int inc[bg]; int l[bg]; int r[bg]; int par[bg]; int swi[bg]; int swipos[bg]; int tri[bg]; int tripos[bg]; int scnt; int tcnt; vector<int> c; vector<int> x; vector<int> y; int nx; void rem(int num){ bad[num]=0; if(inc[num]==0){return;} int n1 = num + inc[num]; int n2 = num + 2*inc[num]; rem(n1); rem(n2); } void create_circuit(int m, vector<int> a){ for(int i=0; i<1000000; i++){ bad[i]=0; } n = a.size(); int anew[bg]; for(int i=0; i<n; i++){ anew[i]=a[i]; } anew[n]=0; po[0]=1; for(int i=1; i<=19; i++){ po[i] = 2*po[i-1]; } c.push_back(a[0]); for(int i=1; i<=m; i++){ c.push_back(-1); } for(int i=0; i<20; i++){ if(po[i]>=n){ nx=i; break; } } for(int i=0; i<nx; i++){ for(int j=po[i]; j<po[i+1]; j++){ l[j] = j+po[i]; r[j] = j+po[i+1]; par[j+po[i]] = j; par[j+po[i+1]] = j; inc[j] = po[i]; } } for(int i=po[nx]; i<po[nx+1]; i++){ inc[i]=0; } int lf=po[nx]-n; int bi[30]; for(int i=19; i>=0; i--){ if(lf>=po[i]){ bi[i]=1; li -= po[i]; } else { bi[i]=0; } } for(int i=0; i<=nx; i++){ if(bi[nx-i]==1){ int imp; for(int j=po[i]; j<po[i+1]; j++){ if(bad[j]==0){ imp=j; break; } } rem(imp); } } scnt=0; tcnt=0; for(int i=po[nx]; i<po[nx+1]; i++){ if(bad[i]==0){ tcnt++; tri[tcnt]=i; tripos[i]=tcnt; } } for(int i=1; i<po[nx]; i++){ if(bad[i]==0){ scnt++; swi[scnt]=i; swipos[i]=scnt; } } for(int i=1; i<=scnt; i++){ int k = swi[i]; if(bad[l[k]]==1){ x.push_back(-1); } else if(inc[l[k]]==0){ x.push_back(anew[tripos[l[k]]]); } else { x.push_back(-swipos[l[k]]); } if(bad[r[k]]==1){ y.push_back(-1); } else if(inc[r[k]]==0){ y.push_back(anew[tripos[l[k]]]); } else { y.push_back(-swipos[r[k]]); } } answer(c,x,y); }

Compilation message (stderr)

doll.cpp:9:9: error: size of array 'inc' is not an integral constant-expression
    9 | int inc[bg];
      |         ^~
doll.cpp:10:9: error: size of array 'l' is not an integral constant-expression
   10 |   int l[bg];
      |         ^~
doll.cpp:11:9: error: size of array 'r' is not an integral constant-expression
   11 |   int r[bg];
      |         ^~
doll.cpp:12:11: error: size of array 'par' is not an integral constant-expression
   12 |   int par[bg];
      |           ^~
doll.cpp:13:11: error: size of array 'swi' is not an integral constant-expression
   13 |   int swi[bg];
      |           ^~
doll.cpp:14:14: error: size of array 'swipos' is not an integral constant-expression
   14 |   int swipos[bg];
      |              ^~
doll.cpp:15:11: error: size of array 'tri' is not an integral constant-expression
   15 |   int tri[bg];
      |           ^~
doll.cpp:16:14: error: size of array 'tripos' is not an integral constant-expression
   16 |   int tripos[bg];
      |              ^~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:94:7: error: 'li' was not declared in this scope; did you mean 'i'?
   94 |       li -= po[i];
      |       ^~
      |       i