#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int maxn = 1001;
int pref [maxn][maxn];
int sg [maxn][maxn];
int a[maxn];
int n;
void build (int l, int r) {
int mid = (l + r) / 2;
if (l >= r) return;
for (int i = mid; i >= l; i--){
for (int j = mid; j <= r; j++){
sg[i][j] = mid;
}
}
for (int i = mid + 2; i <= r; i++){
pref[mid + 1][i] = Secret(pref[mid + 1][i-1], a[i]);
}
for (int i = mid - 1; i >= l; i--){
pref[i][mid] = Secret(pref[i + 1][mid], a[i]);
}
build (l, mid);
build (mid + 1, r);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; i++){
a[i] = A[i];
pref[i][i] = a[i];
}
build(0, n - 1);
}
int Query(int L, int R) {
int mid = sg[L][R];
if (pref[L][R]) return pref[L][R];
return Secret(pref[L][mid], pref[mid + 1][R]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
118 ms |
6436 KB |
Wrong Answer: Query(113, 206) - expected : 536899947, actual : 538256673. |
2 |
Incorrect |
118 ms |
6476 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
129 ms |
6420 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
440 ms |
12344 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
444 ms |
12116 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Incorrect |
435 ms |
12160 KB |
Wrong Answer: Query(653, 654) - expected : 227441904, actual : 93182529. |
7 |
Incorrect |
456 ms |
12168 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
427 ms |
12184 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
443 ms |
12260 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
432 ms |
12080 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |