# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
838714 |
2023-08-27T15:49:23 Z |
vjudge1 |
Secret (JOI14_secret) |
C++17 |
|
412 ms |
4540 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 |
117 ms |
2428 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
116 ms |
2412 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
118 ms |
2484 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
392 ms |
4368 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
390 ms |
4248 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
412 ms |
4312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
390 ms |
4284 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
390 ms |
4364 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
392 ms |
4360 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
391 ms |
4540 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |