#include <bits/stdc++.h>
using namespace std;
int Secret(int X, int Y);
int ans[1005][1005], N;
void calc (int l, int r) {
if (r-l < 2) return;
int mid = (l+r)/2;
for (int i = mid-1; i >= l; i--) ans[i][mid] = Secret(i, mid);
for (int i = mid+2; i <= r; i++) ans[mid+1][i] = Secret(mid+1, i);
calc(l, mid);
calc(mid+1, r);
}
void Init (int n, int A[]) {
N = n;
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans[i][j] = -1;
for (int i = 0; i < n; i++) ans[i][i] = A[i];
calc(0, n-1);
}
int solve (int l, int r, int ql, int qr) {
int mid = (l+r)/2;
if (qr <= mid) return solve(l, mid, ql, qr);
if (mid+1 <= l) return solve(mid+1, r, ql, qr);
return Secret(ans[ql][mid], ans[mid+1][qr]);
}
int Query (int L, int R) {
if (ans[L][R] != -1) return ans[L][R];
return solve(0, N-1, L, R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
99 ms |
6584 KB |
Wrong Answer [1] |
2 |
Incorrect |
99 ms |
6824 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 271581344. |
3 |
Incorrect |
101 ms |
6828 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 564398162. |
4 |
Incorrect |
374 ms |
8528 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 393773658. |
5 |
Incorrect |
379 ms |
8372 KB |
Wrong Answer [1] |
6 |
Incorrect |
374 ms |
8268 KB |
Wrong Answer [1] |
7 |
Incorrect |
370 ms |
8364 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 676897831. |
8 |
Incorrect |
369 ms |
8268 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 547447763. |
9 |
Incorrect |
372 ms |
8272 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 1975398. |
10 |
Incorrect |
372 ms |
8268 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 808152387. |