#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
// Secret(int x, int y);
int calc[1 << 10][1 << 10];
void Init(int N, int A[]) {
memset(calc, -1, sizeof calc);
for (int i = 0; i < N; i++)
calc[i][i] = A[i];
for (int i = 10; i; i --) {
for (int L = 0; L < N; L += 1 << i) {
int M = min(N, L + (1 << (i - 1)));
int R = min(N - 1, L + (1 << i));
for (int j = M + 1; j <= R; j++)
calc[M][j] = Secret(calc[M][j - 1], A[j]);
for (int j = M - 2; j >= L; j--)
calc[j][M - 1] = Secret(calc[j + 1][M - 1], A[j]);
}
}
}
int Query(int L, int R) {
if (calc[L][R] >= 0)
return calc[L][R];
for (int M = L; M < R; M++) {
if (calc[L][M] >= 0 && calc[M + 1][R] >= 0)
return Secret(calc[L][M], calc[M + 1][R]);
}
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
32 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
115 ms |
6464 KB |
Wrong Answer: Query(113, 206) - expected : 536899947, actual : 538256673. |
2 |
Incorrect |
116 ms |
6560 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
117 ms |
6552 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 162768982. |
4 |
Incorrect |
424 ms |
8372 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 546373765. |
5 |
Incorrect |
442 ms |
8408 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 707448136. |
6 |
Incorrect |
427 ms |
8348 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 722663411. |
7 |
Incorrect |
448 ms |
8568 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 54559803. |
8 |
Incorrect |
452 ms |
8648 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 822146056. |
9 |
Incorrect |
426 ms |
8428 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 408296780. |
10 |
Incorrect |
426 ms |
8436 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 67347979. |