# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54501 | ikura355 | Secret (JOI14_secret) | C++14 | 641 ms | 9676 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"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int n;
int a[maxn];
int rec[maxn][maxn];
void prep(int l, int r) {
if(l==r) return ;
int mid = (l+r)/2;
rec[mid][mid] = a[mid];
for(int i=mid-1;i>=l;i--) rec[i][mid] = Secret(a[i], rec[i+1][mid]);
rec[mid+1][mid+1] = a[mid+1];
for(int i=mid+2;i<=r;i++) rec[mid+1][i] = Secret(rec[mid+1][i-1], a[i]);
prep(l,mid); prep(mid+1,r);
}
void Init(int N, int A[]) {
n = N;
for(int i=1;i<=n;i++) a[i] = A[i-1];
for(int i=1;i<=n;i++) {
for(int j=1;j<=n;j++) {
rec[i][j] = -1;
}
}
prep(1,n);
}
int Query(int L, int R) {
L++; R++;
if(rec[L][R]!=-1) return rec[L][R];
for(int i=L;i<R;i++) {
if(rec[L][i]!=-1 && rec[i+1][R]!=-1) {
return Secret(rec[L][i], rec[i+1][R]);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |