# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
573976 | Vanilla | Secret (JOI14_secret) | C++17 | 461 ms | 12136 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int maxn = 1005;
long long pref [maxn][maxn];
void build (int l, int r) {
if (l >= r) return;
int mid = (l + r) / 2;
for (int i = mid - 1; i >= l; i--){
pref[i][mid] = Secret(pref[i + 1][mid], pref[i][i]);
}
for (int i = mid + 2; i < r; i++){
pref[mid + 1][i] = Secret(pref[mid + 1][i-1], pref[i][i]);
}
build (l, mid);
build (mid + 1, r);
}
void Init(int N, int A[]) {
for (int i = 0; i < N; i++){
for (int j = 0; j < N; j++) {
pref[i][j] = -1;
}
pref[i][i] = A[i];
}
build(0, N);
}
int Query(int L, int R) {
if (pref[L][R] != -1) return pref[L][R];
for (int i = L; i < R; i++){
if (pref[L][i] != -1 && pref[i + 1][R] != -1)
return Secret(pref[L][i], pref[i + 1][R]);
}
assert(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |