Submission #959810

# Submission time Handle Problem Language Result Execution time Memory
959810 2024-04-09T07:08:24 Z irmuun Secret (JOI14_secret) C++17
100 / 100
365 ms 11704 KB
#include<bits/stdc++.h>
#include "secret.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

const ll maxn=1e3+5;

int n;
vector<pair<int,int>>v;
int pre[maxn][maxn],suf[maxn][maxn];
int a[maxn];
void build(int l,int r){
    if(l+1>=r) return;
    int mid=(l+r)/2;
    suf[mid][mid]=a[mid];
    for(int i=mid-1;i>=l;i--){
        suf[mid][i]=Secret(a[i],suf[mid][i+1]);
    }
    pre[mid+1][mid+1]=a[mid+1];
    for(int i=mid+2;i<=r;i++){
        pre[mid+1][i]=Secret(pre[mid+1][i-1],a[i]);
    }
    build(l,mid);
    build(mid+1,r);
}
int ask(int l,int r,int L,int R){
    int mid=(l+r)/2;
    if(R<=mid){
        return ask(l,mid,L,R);
    }
    if(L>=mid+1){
        return ask(mid+1,r,L,R);
    }
    return Secret(suf[mid][L],pre[mid+1][R]);
}
void Init(int N,int A[]){
    n=N;
    for(int i=0;i<n;i++){
        a[i]=A[i];
    }
    build(0,n-1);
}
int Query(int l,int r){
    if(l==r){
        return a[l];
    }
    if(l+1==r){
        return Secret(a[l],a[r]);
    }
    return ask(0,n-1,l,r);
}
# Verdict Execution time Memory Grader output
1 Correct 104 ms 10832 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 116 ms 10920 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 104 ms 10920 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 357 ms 11600 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 364 ms 11692 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 358 ms 11704 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 365 ms 11688 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 358 ms 11692 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 358 ms 11596 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 358 ms 11608 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1