# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62645 | Diuven | Secret (JOI14_secret) | C++11 | 742 ms | 9556 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 <assert.h>
static int A[1010];
static int B[1010][1010];
static int n;
void init(int s, int e){
if(s==e){ B[s][s]=A[s]; return; }
if(e<s) return;
int m=(s+e)/2;
init(s,m-1); init(m+1,e);
B[m][m]=A[m], B[m+1][m+1]=A[m+1];
for(int i=m-1; i>=s; i--) B[i][m]=Secret(A[i], B[i+1][m]);
for(int i=m+1; i<=e; i++) B[m+1][i]=Secret(B[m+1][i-1], A[i]);
}
int get(int s, int e, int l, int r){
int m=(s+e)/2;
if(l<=m && m<=r) return m;
if(r<m) return get(s,m-1,l,r);
if(m<l) return get(m+1,e,l,r);
assert(true);
}
void Init(int N, int _A[]){
n=N;
for(int i=0; i<n; i++) A[i]=_A[i];
init(0,n-1);
}
int Query(int l, int r){
if(l==r) return A[l];
int m=get(0,n-1,l,r);
return Secret(B[l][m], B[m+1][r]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |