#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100;
int prefix[maxn][maxn];
int suffix[maxn][maxn];
int arr[maxn], n;
void precompute(int l, int r) {
if(l == r) prefix[l][l] = suffix[l][l] = arr[l];
else {
int mid = (l + r) / 2;
prefix[mid][mid] = suffix[mid][mid] = arr[mid];
for(int i=mid-1;i>=l;i--) {
suffix[mid][i] = Secret(arr[i], suffix[mid][i+1]);
}
for(int i=mid+1;i<=r;i++) {
prefix[mid][i] = Secret(prefix[mid][i-1], arr[i]);
}
precompute(l, mid);
precompute(mid+1,r);
}
}
void Init(int N, int A[]) {
n = N;
for(int i=0;i<n;i++) {
arr[i] = A[i];
}
precompute(0, n-1);
}
int solve(int ql, int qr, int li=0, int ri=n-1) {
if(li == ri) return arr[li];
else {
int mid = (li + ri) / 2;
if(ql <= mid && qr > mid) {
//cout<<ql<<", "<<qr<<" mid point: "<<mid<<"Here: ["<<li<<", "<<ri<<"]\n";
return Secret(suffix[mid][ql], prefix[mid][qr]);
}
else if(qr <= mid) {
return solve(ql, qr, li, mid);
}
else {
return solve(ql, qr, mid+1, ri);
}
}
}
int Query(int L, int R) {
return solve(L, R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
162 ms |
6648 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 318854190. |
2 |
Incorrect |
164 ms |
6776 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 534774241. |
3 |
Incorrect |
165 ms |
6652 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 204699730. |
4 |
Incorrect |
593 ms |
12440 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 273285253. |
5 |
Incorrect |
599 ms |
12512 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 509231116. |
6 |
Incorrect |
594 ms |
12552 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 707400362. |
7 |
Incorrect |
598 ms |
12512 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 9155594. |
8 |
Incorrect |
595 ms |
12516 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 828815616. |
9 |
Incorrect |
594 ms |
12508 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 700983590. |
10 |
Incorrect |
596 ms |
12720 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 813517315. |