Submission #53188

# Submission time Handle Problem Language Result Execution time Memory
53188 2018-06-29T00:29:15 Z okaybody10 Secret (JOI14_secret) C++
100 / 100
628 ms 8612 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
int n,B[1006],ans[1006][1006];
void _init(int s,int e)
{
    int m=(s+e)/2;
    if(s==e){
        ans[m][m]=B[m];
        return;
    }
    ans[m][m]=B[m];
    ans[m+1][m+1]=B[m+1];
    for(int i=m-1;i>=s;i--) ans[i][m]=Secret(B[i],ans[i+1][m]);
    for(int i=m+2;i<=e;i++) ans[m+1][i]=Secret(ans[m+1][i-1],B[i]);
    _init(s,m);
    _init(m+1,e);
}
void Init(int N, int A[]) {
    n=N;
    for(int i=0; i<n; i++) B[i]=A[i];
    _init(0,n-1);
}
int solve(int l,int r,int s,int e)
{
    int m=(s+e)/2;
    if(l<=m && m+1<=r) return Secret(ans[l][m],ans[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[r];
    return solve(l,r,0,n-1);
}
# Verdict Execution time Memory Grader output
1 Correct 173 ms 4388 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 171 ms 4456 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 168 ms 4728 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 599 ms 8428 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 588 ms 8532 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 593 ms 8556 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 586 ms 8612 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 598 ms 8612 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 628 ms 8612 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 585 ms 8612 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1