# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411468 | benedict0724 | Secret (JOI14_secret) | C++17 | 531 ms | 8484 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |