#include "secret.h"
using ll = long long;
int val[12][1005], a[1005], n;
void precalc(ll l, ll r, ll la){
ll m = (l+r)>>1;
val[la][m] = a[m];
if(l >= r)return;
if(l<=m-1)val[la][m-1] = a[m-1];
for(ll i = m+1;i<=r;i++)val[la][i]=Secret(val[la][i-1],a[i]);
for(ll i = m-2;i>=l;i--)val[la][i]=Secret(val[la][i+1],a[i]);
precalc(l,m-1,la+1);
precalc(m+1,r,la+1);
}
void Init(int N, int A[]){
for(ll i = 0;i<N;i++)a[i] = A[i];
precalc(0,N-1,0);
n = N;
}
int query(int L, int R, ll l = 0, ll r = n-1, ll la = 0){
ll m = (l+r)>>1;
if(L <= m && m <= R){
if(L!=m)
return Secret(val[la][L],val[la][R]);
return val[la][R];
}
if(m > L)return query(L,R,l,m,la+1);
return query(L,R,m+1,r,la+1);
}
int Query(int L, int R){
return query(L,R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
121 ms |
2444 KB |
Wrong Answer: Query(113, 206) - expected : 536899947, actual : 50471211. |
2 |
Incorrect |
126 ms |
2392 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 29530216. |
3 |
Incorrect |
114 ms |
2484 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 162768982. |
4 |
Incorrect |
436 ms |
4428 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 858309235. |
5 |
Incorrect |
420 ms |
4388 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 602966360. |
6 |
Incorrect |
459 ms |
4408 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 0. |
7 |
Incorrect |
419 ms |
4292 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 578359305. |
8 |
Incorrect |
439 ms |
4320 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 633393600. |
9 |
Incorrect |
418 ms |
4360 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 148126725. |
10 |
Incorrect |
438 ms |
4300 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 275769990. |