# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
466745 |
2021-08-20T15:35:05 Z |
nkato |
Secret (JOI14_secret) |
C++17 |
|
533 ms |
8224 KB |
#include "secret.h"
int prefix[1000][1000], n;
void populate(int L, int R, int A[]) {
int mid = (L + R) / 2;
prefix[mid][mid] = A[mid];
prefix[mid + 1][mid + 1] = A[mid + 1];
for (int i = mid + 2; i <= R; i++)
prefix[mid + 1][i] = Secret(prefix[mid + 1][i - 1], A[i]);
for (int i = mid - 1; i >= L; i--)
prefix[mid][i] = Secret(A[i], prefix[mid][i + 1]);
if (L < mid) populate(L, mid, A);
if (mid + 1 < R) populate(mid + 1, R, A);
}
void Init(int N, int A[]) {
n = N;
populate(0, N - 1, A);
}
int Query(int L, int R) {
int a = 0, b = n - 1;
while (a != b) {
int mid = (a + b) / 2;
if (mid >= L && mid < R)
return Secret(prefix[mid][L], prefix[mid + 1][R]);
else if (mid == R) return prefix[mid][L];
else if (mid < L) a = mid + 1;
else b = mid;
}
return prefix[a][a];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
164 ms |
4276 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
145 ms |
4332 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
165 ms |
4316 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
517 ms |
8152 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
513 ms |
8052 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
506 ms |
8056 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
516 ms |
8224 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
516 ms |
8152 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
533 ms |
8100 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
515 ms |
8132 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |