# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
838713 |
2023-08-27T15:48:58 Z |
adaawf |
Secret (JOI14_secret) |
C++14 |
|
411 ms |
4460 KB |
#include "secret.h"
#include <iostream>
using namespace std;
int f[11][1005], g[11][1005], a[1005], n, res;
void dnc(int l, int r, int x) {
if (l >= r) return;
int mid = (l + r) / 2;
f[x][mid] = a[mid];
for (int i = mid - 1; i >= l; i--) {
f[x][i] = Secret(a[i], f[x][i + 1]);
}
g[x][mid + 1] = a[mid + 1];
for (int i = mid + 2; i <= r; i++) {
g[x][i] = Secret(g[x][i - 1], a[i]);
}
dnc(l, mid, x + 1);
dnc(mid + 1, r, x + 1);
}
void trya(int tl, int tr, int l, int r, int x) {
if (l >= r) {
return;
}
int mid = (l + r) / 2;
if (l <= tl && tl <= mid && mid + 1 <= tr && tr <= r) {
res = Secret(f[x][tl], g[x][tr]);
return;
}
trya(tl, tr, l, mid, x + 1);
trya(tl, tr, mid + 1, r, x + 1);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; i++) {
a[i] = A[i];
}
dnc(0, n - 1, 1);
}
int Query(int L, int R) {
if (L == R) {
return a[L];
}
res = 0;
trya(L, R, 0, n - 1, 1);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
2420 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
113 ms |
2508 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
120 ms |
2508 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
395 ms |
4456 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
395 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
411 ms |
4428 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
393 ms |
4440 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
391 ms |
4400 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
387 ms |
4384 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
403 ms |
4380 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |