#include "secret.h"
int n;
int pre[1010][1010] = {};
void process(int L, int R, int A[]) {
if(L == R) return;
int m = (L + R)/2;
pre[m][m] = A[m];
pre[m+1][m+1] = A[m+1];
for(int i = m-1; i >= L; i--) {
pre[m][i] = Secret(A[i], pre[m][i+1]);
}
for(int i = m+2; i <= R; i++) {
pre[m+1][i] = Secret(pre[m+1][i-1], A[i]);
}
process(L, m, A);
process(m+1, R, A);
}
void Init(int N, int A[]) {
n = N;
process(0, N-1, A);
}
int Query(int L, int R) {
int lo = 0, hi = n-1;
while(lo < hi) {
int mid = (lo + hi)/2;
if(L <= mid && R >= mid + 1) {
return Secret(pre[L][mid], pre[mid+1][R]);
} else if(R == mid) {
return pre[L][mid];
}
if(R < mid + 1) {
hi = mid;
} else {
lo = mid + 1;
}
}
return pre[lo][lo];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
116 ms |
4288 KB |
Wrong Answer: Query(113, 206) - expected : 536899947, actual : 269891210. |
2 |
Incorrect |
119 ms |
4384 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 712055264. |
3 |
Incorrect |
120 ms |
4464 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 539361598. |
4 |
Incorrect |
432 ms |
8120 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 374358039. |
5 |
Incorrect |
419 ms |
8236 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 483966986. |
6 |
Incorrect |
426 ms |
8268 KB |
Wrong Answer: Query(811, 813) - expected : 25091616, actual : 162759528. |
7 |
Incorrect |
423 ms |
8288 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 177907722. |
8 |
Incorrect |
422 ms |
8256 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 489869504. |
9 |
Incorrect |
429 ms |
8208 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 702032905. |
10 |
Incorrect |
425 ms |
8268 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 336488262. |