#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1024;
int a[MAXN],n;
int pre[MAXN][10];
void dq(int l,int r,int d)
{
if(l+1==r)return;
int mid=(l+r)/2;
pre[d][mid]=a[mid];
for(int i=mid-1;i>=l;i--)pre[d][i]=Secret(pre[d][i+1],a[i]);
pre[d][mid+1]=a[mid+1];
for(int i=mid+2;i<=r;i++)pre[d][i]=Secret(pre[d][i-1],a[i]);
dq(l,mid,d+1);dq(mid+1,r,d+1);
}
void Init(int N, int A[]) {
for(int i=0;i<N;i++)a[i]=A[i];
dq(0,N-1,0);n=N;
}
int dq_query(int l,int r,int l1,int r1,int d)
{
int mid=(l+r)/2;
if(l1<=mid&&r1>=mid)
{
return Secret(pre[d][r1],pre[d][l1]);
}
if(r1<=mid)return dq_query(l,mid,l1,r1,d+1);
else return dq_query(mid+1,r,l1,r1,d+1);
}
int Query(int L, int R) {
if(L==R)return a[L];
if(L+1==R)return Secret(a[L],a[R]);
return dq_query(0,n-1,L,R,0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
138 ms |
6124 KB |
Execution killed with signal 11 |
2 |
Incorrect |
137 ms |
2540 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 258021794. |
3 |
Runtime error |
135 ms |
6124 KB |
Execution killed with signal 11 |
4 |
Runtime error |
523 ms |
10092 KB |
Execution killed with signal 11 |
5 |
Runtime error |
515 ms |
9860 KB |
Execution killed with signal 11 |
6 |
Runtime error |
498 ms |
10220 KB |
Execution killed with signal 11 |
7 |
Runtime error |
497 ms |
9964 KB |
Execution killed with signal 11 |
8 |
Runtime error |
522 ms |
9964 KB |
Execution killed with signal 11 |
9 |
Runtime error |
507 ms |
10136 KB |
Execution killed with signal 11 |
10 |
Runtime error |
506 ms |
10008 KB |
Execution killed with signal 11 |