# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
984432 |
2024-05-16T16:19:29 Z |
LOLOLO |
Secret (JOI14_secret) |
C++14 |
|
364 ms |
8524 KB |
//#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int N = 1e3 + 10;
int n;
int a[N], f[N][N];
void prepare(int l, int r) {
if (l >= r) {
f[l][l] = a[l];
return;
}
int m = (l + r) / 2;
f[m][m] = a[m];
f[m + 1][m + 1] = a[m + 1];
for (int j = m + 2; j <= r; j++) {
f[m + 1][j] = Secret(f[m + 1][j - 1], a[j]);
}
for (int j = m - 1; j >= l; j--) {
f[j][m] = Secret(a[j], f[j + 1][m]);
}
prepare(l, m);
prepare(m + 1, r);
}
void Init(int _n, int _a[]) {
n = _n;
for (int i = 0; i < n; i++)
a[i] = _a[i];
prepare(0, n - 1);
}
int get(int l, int r, int u, int v) {
int m = (l + r) / 2;
if (m < u)
return get(m + 1, r, u, v);
if (m > v)
return get(l, m, u, v);
if (v == m)
return f[u][v];
return Secret(f[u][m], f[m + 1][v]);
}
int Query(int l, int r) {
if (l == r) {
return a[l];
}
return get(0, n - 1, l, r);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
7508 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
104 ms |
7828 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
103 ms |
7496 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
355 ms |
8100 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
358 ms |
8524 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
355 ms |
8296 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
362 ms |
8200 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
364 ms |
8200 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
361 ms |
8276 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
360 ms |
8268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |