#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
const int MAXN = 1010;
int N, ans[MAXN][MAXN];
void divide_and_conquer(int l, int r)
{
if(r - l <= 1) return;
int mid = (l + r) >> 1;
for(int i = mid - 1; l <= i; i--) ans[i][mid] = Secret(ans[i][i], ans[i + 1][mid]);
for(int i = mid + 2; i <= r; i++) ans[mid][i] = Secret(ans[mid][i - 1], ans[i][i]);
divide_and_conquer(l, mid);
divide_and_conquer(mid + 1, r);
}
void Init(int n, int a[])
{
N = n;
for(int i = 0; i < n; i++) ans[i][i] = a[i];
divide_and_conquer(0, N - 1);
}
int findAns(int l, int r, int L, int R)
{
int mid = (l + r) >> 1;
if(L <= mid && mid + 1 <= R) return Secret(ans[L][mid], ans[mid + 1][R]);
if(R <= mid) return findAns(l, mid, L, R);
else return findAns(mid + 1, r, L, R);
}
int Query(int l, int r)
{
if(r - l <= 1) return Secret(ans[l][l], ans[r][r]);
return findAns(0, N - 1, l, r);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
133 ms |
4460 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 805576266. |
2 |
Incorrect |
132 ms |
4460 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 571476064. |
3 |
Incorrect |
133 ms |
4460 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136730926. |
4 |
Incorrect |
493 ms |
8428 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 870547617. |
5 |
Incorrect |
493 ms |
8300 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 976357712. |
6 |
Incorrect |
496 ms |
8300 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 31281100. |
7 |
Incorrect |
494 ms |
8300 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 781793354. |
8 |
Incorrect |
499 ms |
8292 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 499418120. |
9 |
Incorrect |
494 ms |
8300 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 277351906. |
10 |
Incorrect |
500 ms |
8300 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 274498057. |