#include "secret.h"
int prefix[1006][1006];
int n;
void precompute(int l,int r,int A[])
{
int mid = (l+r)/2;
prefix[mid][mid]=A[mid];
prefix[mid+1][mid+1]=A[mid+1];
for(int i=mid+2;i<=r;i++)
prefix[mid+1][i] = Secret(prefix[mid+1][i-1],A[i]);
for(int i=mid-1;i>=l;i--)
prefix[mid][i] = Secret(A[i],prefix[mid][i+1]);//reda ima znachenie - bqha naobratno parametrite
if(mid+1<r)
precompute(mid+1,r,A);
if(mid>l)
precompute(l,mid,A);
}
void Init(int N, int A[])
{
n=N;
precompute(0,N-1,A);
}
int Query(int L, int R)
{
int l = 0, r = n-1;
while(l!=r)
{
int mid = (l+r)/2;
if(mid>=L && mid+1<=R)
return Secret(prefix[mid][L],prefix[mid+1][R]);
else if(mid==R)
return prefix[mid][L];
else if(mid>L)
l=mid+1;
else r=mid;
}
return prefix[l][l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
111 ms |
4292 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 847844452. |
2 |
Incorrect |
112 ms |
4276 KB |
Wrong Answer: Query(102, 157) - expected : 32612619, actual : 71755278. |
3 |
Incorrect |
111 ms |
4336 KB |
Wrong Answer: Query(334, 369) - expected : 363022362, actual : 423168042. |
4 |
Incorrect |
412 ms |
8200 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 615503535. |
5 |
Incorrect |
413 ms |
8160 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 423036959. |
6 |
Incorrect |
415 ms |
8084 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 422971424. |
7 |
Correct |
425 ms |
8268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
423 ms |
8168 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
425 ms |
8116 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
419 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |