Submission #1271218

#TimeUsernameProblemLanguageResultExecution timeMemory
1271218repmannSecret (JOI14_secret)C++20
0 / 100
339 ms8324 KiB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
int N, glob;
int A[1001];
int DP[1001][1001];
inline void Divide(int L, int R)
{
  if((R - L) <= 1) return;
  int S = (L + R) >> 1;
  for(int i = S - 1; i >= L; i--) {glob++; while(glob >= 8000); DP[S][i] = Secret(A[i], DP[S][i + 1]);}
  for(int i = S + 2; i <= R; i++) {glob++; while(glob >= 8000); DP[S + 1][i] = Secret(DP[S + 1][i - 1], A[i]);}
  Divide(L, S - 1);
  Divide(S + 2, R);
  return;
}
void Init(int n, int *a)
{
  N = n;
  for(int i = 1; i <= N; i++) A[i] = a[i - 1];
  for(int i = 1; i <= N; i++)
  {
    for(int j = 1; j <= N; j++) DP[i][j] = -1;
    DP[i][i] = A[i];
  }
  Divide(1, N);
  return;
}
int Query(int L, int R)
{
  L++, R++;
  if(L == R) return A[L];
  for(int i = L; i < R; i++) if((DP[i][L] > 0) && (DP[i + 1][R] > 0)) return Secret(DP[i][L], DP[i + 1][R]);
  exit(333);
}
#Verdict Execution timeMemoryGrader output
Fetching results...