#include "secret.h"
#include <algorithm>
using namespace std;
int t[10][1005];
int *pt;
void make(int depth, int A[], int N, int piv){
if(depth == -1) return;
make(depth-1,A,N,piv - (1<<(depth-1)));
make(depth-1,A,N,piv + (1<<(depth-1)));
if(N <= piv) return;
t[depth][piv-1] = A[piv-1];
t[depth][piv] = A[piv];
for (int i=piv-2; i>=piv - (1<<depth); i--) {
t[depth][i] = Secret(A[i],t[depth][i+1]);
}
for (int i=piv+1; i<piv + (1<<depth) && i < N; i++) {
t[depth][i] = Secret(t[depth][i-1],A[i]);
}
}
void Init(int N, int A[]){
pt = A;
make(9,A,N,512);
}
int q(int p, int l, int r, int d){
if(d == 0) return pt[p];
if(l <= p-1 && p <= r) return Secret(t[d][l],t[d][r]);
if(r <= p-1) return q(p-(1<<(d-1)),l,r,d-1);
return q(p+(1<<(d-1)),l,r,d-1);
}
int Query(int L, int R){
return q(512,L,R,9);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
166 ms |
5148 KB |
Wrong Answer: Query(182, 183) - expected : 213483071, actual : 799897660. |
2 |
Incorrect |
153 ms |
5148 KB |
Wrong Answer: Query(210, 211) - expected : 558550312, actual : 411169824. |
3 |
Incorrect |
159 ms |
5148 KB |
Wrong Answer: Query(130, 131) - expected : 127065177, actual : 117796147. |
4 |
Incorrect |
613 ms |
5148 KB |
Wrong Answer: Query(788, 788) - expected : 937598145, actual : 819650627. |
5 |
Incorrect |
606 ms |
5148 KB |
Wrong Answer: Query(540, 541) - expected : 886637908, actual : 276558328. |
6 |
Incorrect |
626 ms |
5148 KB |
Wrong Answer: Query(780, 780) - expected : 253540469, actual : 655871763. |
7 |
Correct |
636 ms |
5148 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
616 ms |
5148 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
609 ms |
5148 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
619 ms |
5148 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |