# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
481737 | jk410 | Secret (JOI14_secret) | C++17 | 432 ms | 8192 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 N;
int A[1000],Ans[1000][1000];
void init_tree(int s,int e){
if (s==e)
return;
int m=(s+e)>>1;
Ans[m][m]=A[m];
Ans[m+1][m+1]=A[m+1];
for (int i=m-1; i>=s; i--)
Ans[i][m]=Secret(A[i],Ans[i+1][m]);
for (int i=m+2; i<=e; i++)
Ans[m+1][i]=Secret(Ans[m+1][i-1],A[i]);
init_tree(s,m);
init_tree(m+1,e);
}
void Init(int n,int a[]){
N=n;
for (int i=0; i<N; i++)
A[i]=a[i];
init_tree(0,N-1);
}
int query_tree(int s,int e,int l,int r){
int m=(s+e)>>1;
if (l>m)
return query_tree(m+1,e,l,r);
if (r<=m)
return query_tree(s,m,l,r);
return Secret(Ans[l][m],Ans[m+1][r]);
}
int Query(int l,int r){
if (l==r)
return A[l];
return query_tree(0,N-1,l,r);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |