Submission #53161

# Submission time Handle Problem Language Result Execution time Memory
53161 2018-06-28T21:43:41 Z okaybody10 Secret (JOI14_secret) C++
100 / 100
623 ms 8532 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
 
const int MX=1001;
 
int n, B[MX];
 
int D[MX][MX];
 
void _fill(int s=0, int e=n-1){
    int m=(s+e)/2;
    if(s==e){
        D[m][m]=B[m];
        return;
    }
    D[m][m]=B[m];
    for(int x=m-1; x>=s; x--){
        D[x][m]=Secret(B[x], D[x+1][m]);
    }
    D[m+1][m+1]=B[m+1];
    for(int y=m+2; y<=e; y++)
        D[m+1][y]=Secret(D[m+1][y-1], B[y]);
    _fill(s,m);
    _fill(m+1,e);
}
 
void Init(int N, int A[]) {
    n=N;
    for(int i=0; i<n; i++) B[i]=A[i];
    _fill();
}
int solve(int l, int r, int s=0, int e=n-1){
    int m=(s+e)/2;
    if(l<=m && m+1<=r){
        return Secret(D[l][m], D[m+1][r]);
    }
    if(r<=m) return solve(l,r,s,m);
    else return solve(l,r,m+1,e);
}
 
int Query(int l, int r) {
    if(l==r) return B[l];
    return solve(l,r);
}
# Verdict Execution time Memory Grader output
1 Correct 167 ms 4372 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 181 ms 4452 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 176 ms 4632 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 576 ms 8472 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 623 ms 8472 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 611 ms 8472 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 598 ms 8472 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 590 ms 8532 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 602 ms 8532 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 601 ms 8532 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1