#include "secret.h"
int N;
int A[1000],Ans[1000][1000];
void init_tree(int s,int e){
if (s==e)
return;
int m=(s+e)>>1;
Ans[m][m]=A[m];
Ans[m+1][m+1]=A[m+1];
for (int i=m-1; i>=s; i--)
Ans[i][m]=Secret(A[i],Ans[i+1][m]);
for (int i=m+2; i<=e; i++)
Ans[m+1][i]=Secret(Ans[m+1][i-1],A[i]);
init_tree(s,m);
init_tree(m+1,e);
}
void Init(int n,int a[]){
N=n;
for (int i=0; i<N; i++)
A[i]=a[i];
init_tree(0,N-1);
}
int query_tree(int s,int e,int l,int r){
int m=(s+e)>>1;
if (l>m)
return query_tree(m+1,e,l,r);
if (r<=m)
return query_tree(s,m,l,r);
return Secret(Ans[l][m],Ans[m+1][r]);
}
int Query(int l,int r){
if (l==r)
return A[l];
return query_tree(0,N-1,l,r);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
121 ms |
4292 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
120 ms |
4344 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
122 ms |
4344 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
419 ms |
8108 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
422 ms |
8168 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
431 ms |
8120 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
423 ms |
8076 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
428 ms |
8136 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
432 ms |
8192 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
426 ms |
8108 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |