#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int n, dp[N][N];
void divi(int l, int r) {
if (l >= r) return;
int m = (l + r) >> 1;
for (int i = m - 1; i >= l; i--) dp[i][m] = Secret(dp[i + 1][m], dp[i][i]);
for (int i = m + 2; i <= r; i++) dp[m + 1][i] = Secret(dp[m + 1][i - 1], dp[i][i]);
divi(l, m);
divi(m + 1, r);
}
void Init(int N, int A[]) {
memset(dp, -1, sizeof dp);
for (int i = 0; i < N; i++) dp[i][i] = A[i];
divi(0, N);
}
int Query(int L, int R) {
if (dp[L][R] != -1) return dp[L][R];
for (int i = L; i < R; i++)
if (dp[L][i] != -1 && dp[i + 1][R] != -1) return Secret(dp[L][i], dp[i + 1][R]);
}
Compilation message (stderr)
secret.cpp: In function 'int Query(int, int)':
secret.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
28 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |