Submission #468353

#TimeUsernameProblemLanguageResultExecution timeMemory
468353stefantagaSecret (JOI14_secret)C++14
100 / 100
571 ms8408 KiB
#include "secret.h" int val[1000][1000]; void init(int l, int r) { if(r - l < 2) return; int mid = (l + r)/2; for(int i=mid-1;i>=l;i--) { if(val[i][mid] != -1) continue; val[i][mid] = Secret(val[i][i], val[i+1][mid]); } for(int j=mid+2;j<=r;j++) { if(val[mid+1][j] != -1) continue; val[mid+1][j] = Secret(val[mid+1][j-1], val[j][j]); } init(l, mid-1); init(mid+1, r); } void Init(int N, int A[]) { for(int i=0;i<N;i++) for(int j=0;j<N;j++) val[i][j] = -1; for(int i=0;i<N;i++) { val[i][i] = A[i]; } init(0, N-1); } int Query(int L, int R) { if(val[L][R] != -1) return val[L][R]; for(int i=L;i<R;i++) { if(val[L][i] != -1 && val[i+1][R] != -1) { return val[L][R] = Secret(val[L][i], val[i+1][R]); } } }

Compilation message (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
   41 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...