Submission #94832

#TimeUsernameProblemLanguageResultExecution timeMemory
94832easruiSecret (JOI14_secret)C++14
30 / 100
581 ms8484 KiB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

int D[1001][1001],NN;

int process(int L, int R)
{
    if(L==R) return D[L][R];
    int M = (L+R)/2;
    return D[L][R] = Secret(process(L,M),process(M+1,R));
}

void Init(int N, int A[]) {
    for(int i=0; i<N; i++) D[i][i] = A[i];
    NN = N;
    process(0,N-1);
}

int getans(int S, int E, int L, int R)
{
    if(L<=S && E<=R) return D[S][E];
    int M = (S+E)/2, P=-1, Q=-1;
    if(M>=L) P = getans(S,M,L,R);
    if(M+1<=R) Q = getans(M+1,E,L,R);
    if(P==-1) return Q;
    if(Q==-1) return P;
    return Secret(P,Q);
}

int Query(int L, int R) {
    return getans(0,NN-1,L,R);
}
#Verdict Execution timeMemoryGrader output
Fetching results...