#include "secret.h"
const int MAXN = 1e3+1;
int SRQ[MAXN][MAXN];
int Arrl[MAXN];
int globul;
void initTree(int l, int r){
if (l == r)return;
int mid = (l+r)>>1;
SRQ[mid][mid] = Arrl[mid];
SRQ[mid+1][mid+1] = Arrl[mid+1];
for (int i = mid-1; i >= l; i--){
SRQ[mid][i] = Secret(Arrl[i], SRQ[mid][i+1]);
}
for (int i = mid+2; i <= r; i++){
SRQ[mid+1][i] = Secret(SRQ[mid+1][i-1], Arrl[i]);
}
initTree(l, mid);
initTree(mid+1, r);
}
int followInit(int l, int r, int wL, int wR){
int mid = (l+r)>>1;
if (mid >= wL && mid < wR)return Secret(SRQ[mid][wL], SRQ[mid+1][wR]);
if (mid == wR){
return SRQ[mid][wL];
}
if (l == r)return SRQ[0][0];
if (mid < wL){
return followInit(mid+1, r, wL, wR);
}
return followInit(l, mid, wL, wR);
}
void Init(int N, int A[]){
for (int i = 0; i < N; i++){
Arrl[i] = A[i];
}
globul = N;
initTree(0, N-1);
}
int Query(int L, int R){
return followInit(0, globul-1, L, R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
7488 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 |
7548 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
104 ms |
7584 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
369 ms |
8300 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
385 ms |
8204 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
362 ms |
8264 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
379 ms |
8356 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
371 ms |
8296 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
360 ms |
8244 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
365 ms |
8208 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |