# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
518937 | valerikk | Secret (JOI14_secret) | C++17 | 449 ms | 8304 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 "secret.h"
#include <assert.h>
#include <string.h>
#include <vector>
static const int N = 1005;
static int n;
static int a[N];
static int b[N][N];
void go(int l, int r) {
if (l == r) {
b[l][r] = a[l];
return;
}
int m = (l + r) / 2;
go(l, m);
for (int i = m - 1; i >= l; i--) {
b[i][m] = Secret(a[i], b[i + 1][m]);
}
go(m + 1, r);
for (int i = m + 2; i <= r; i++) {
b[m + 1][i] = Secret(b[m + 1][i - 1], a[i]);
}
}
void Init(int grader_N, int grader_A[]) {
n = grader_N;
for (int i = 0; i < n; i++) {
a[i] = grader_A[i];
}
memset(b, 255, sizeof(b));
go(0, n - 1);
}
int Query(int grader_L, int grader_R) {
int l = grader_L, r = grader_R;
if (~b[l][r]) {
return b[l][r];
}
for (int m = l; m < r; m++) {
if (~b[l][m] && ~b[m + 1][r]) {
return Secret(b[l][m], b[m + 1][r]);
}
}
assert(false);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |