Submission #67546

#TimeUsernameProblemLanguageResultExecution timeMemory
67546JustasZXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include "xylophone.h" void solve(int n) { int arr[maxn]; int two[maxn], three[maxn], sgn[maxn]; for(int i=1; i<=n-1; i++) two[i]=query(i, i+1); for(int i=1; i<=n-2; i++) three[i]=query(i, i+2); if(three[1]==two[1]+two[2]) sgn[1]=sgn[2]=1; else sgn[1]=1, sgn[2]=-1; for(int i=3; i<=n-1; i++) { if(two[i-1]+two[i]!=three[i-1]) sgn[i]=-sgn[i-1]; else sgn[i]=sgn[i-1]; } arr[1]=1; int mn=INT_MAX; for(int i=2; i<=n; i++) { arr[i]=arr[i-1]+sgn[i-1]*two[i-1]; mn=min(mn, arr[i]); } int add=1-mn; for(int i=1; i<=n; i++) arr[i]+=add; for(int i=1; i<=n; i++) { if(arr[i]==1)break; if(arr[i]==n) { for(int j=1; j<=n; j++) arr[j]=n-arr[j]+1; break; } } for(int i=1; i<=n; i++) answer(i, arr[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:4:13: error: 'maxn' was not declared in this scope
     int arr[maxn];
             ^~~~
xylophone.cpp:7:9: error: 'two' was not declared in this scope
         two[i]=query(i, i+1);
         ^~~
xylophone.cpp:9:9: error: 'three' was not declared in this scope
         three[i]=query(i, i+2);
         ^~~~~
xylophone.cpp:10:8: error: 'three' was not declared in this scope
     if(three[1]==two[1]+two[2])
        ^~~~~
xylophone.cpp:10:18: error: 'two' was not declared in this scope
     if(three[1]==two[1]+two[2])
                  ^~~
xylophone.cpp:11:9: error: 'sgn' was not declared in this scope
         sgn[1]=sgn[2]=1;
         ^~~
xylophone.cpp:11:9: note: suggested alternative: 'signed'
         sgn[1]=sgn[2]=1;
         ^~~
         signed
xylophone.cpp:12:10: error: 'sgn' was not declared in this scope
     else sgn[1]=1, sgn[2]=-1;
          ^~~
xylophone.cpp:12:10: note: suggested alternative: 'signed'
     else sgn[1]=1, sgn[2]=-1;
          ^~~
          signed
xylophone.cpp:15:12: error: 'two' was not declared in this scope
         if(two[i-1]+two[i]!=three[i-1])
            ^~~
xylophone.cpp:15:29: error: 'three' was not declared in this scope
         if(two[i-1]+two[i]!=three[i-1])
                             ^~~~~
xylophone.cpp:16:13: error: 'sgn' was not declared in this scope
             sgn[i]=-sgn[i-1];
             ^~~
xylophone.cpp:16:13: note: suggested alternative: 'signed'
             sgn[i]=-sgn[i-1];
             ^~~
             signed
xylophone.cpp:17:14: error: 'sgn' was not declared in this scope
         else sgn[i]=sgn[i-1];
              ^~~
xylophone.cpp:17:14: note: suggested alternative: 'signed'
         else sgn[i]=sgn[i-1];
              ^~~
              signed
xylophone.cpp:19:5: error: 'arr' was not declared in this scope
     arr[1]=1;
     ^~~
xylophone.cpp:20:12: error: 'INT_MAX' was not declared in this scope
     int mn=INT_MAX;
            ^~~~~~~
xylophone.cpp:20:12: note: suggested alternative: '__INT_MAX__'
     int mn=INT_MAX;
            ^~~~~~~
            __INT_MAX__
xylophone.cpp:23:25: error: 'sgn' was not declared in this scope
         arr[i]=arr[i-1]+sgn[i-1]*two[i-1];
                         ^~~
xylophone.cpp:23:34: error: 'two' was not declared in this scope
         arr[i]=arr[i-1]+sgn[i-1]*two[i-1];
                                  ^~~
xylophone.cpp:24:12: error: 'min' was not declared in this scope
         mn=min(mn, arr[i]);
            ^~~
xylophone.cpp:24:12: note: suggested alternative: 'mn'
         mn=min(mn, arr[i]);
            ^~~
            mn