#include "secret.h"
int range[1000][1000];
int _A[1000], _N;
void pre(int s, int e,int lev) {
if (s >= e) return;
int m = (s + e) >> 1;
for (int i = m - 1; i >= s; --i)
range[i][m] = Secret(_A[i],range[i+1][m]);
pre(s, m - 1,lev+1);
++m;
for (int i = m + 1; i <= e; ++i)
range[m][i] = Secret(range[m][i - 1], _A[i]);
--m;
pre(m+1,e,lev+1);
}
void Init(int N, int A[]) {
_N = N;
for (int i = 0; i < N; ++i) _A[i] =range[i][i]= A[i];
pre(0, N - 1,0);
}
int op(int s,int e,int l,int r) {
int m = (s+e)>>1;
if (m <= r && m + 1 >= l) {
if (r == m || m+1==l) return range[l][r];
return Secret(range[l][m],range[m+1][r]);
}
if (m > r) return op(m+2,e,l,r);
else return op(s,m-1,l,r);
}
int Query(int L, int R) {
if (L == R) return _A[L];
else if (L + 1 == R) return Secret(_A[L], _A[R]);
return op(0,_N-1,L,R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
20062 ms |
4608 KB |
Time limit exceeded |
2 |
Execution timed out |
20068 ms |
4472 KB |
Time limit exceeded |
3 |
Execution timed out |
20065 ms |
4472 KB |
Time limit exceeded |
4 |
Execution timed out |
20059 ms |
8312 KB |
Time limit exceeded |
5 |
Execution timed out |
20086 ms |
8236 KB |
Time limit exceeded |
6 |
Execution timed out |
20020 ms |
8428 KB |
Time limit exceeded |
7 |
Correct |
497 ms |
8416 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
502 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
480 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
533 ms |
8384 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |