#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(A[j], calc[j + 1][M - 1]);
}
}
}
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 |
Correct |
133 ms |
6428 KB |
Output is correct - number of calls to Secret by Init = 4590, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
124 ms |
6376 KB |
Output is correct - number of calls to Secret by Init = 4599, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
131 ms |
6476 KB |
Output is correct - number of calls to Secret by Init = 4608, maximum number of calls to Secret by Query = 1 |
4 |
Partially correct |
456 ms |
8296 KB |
Output isn't correct - number of calls to Secret by Init = 8982, maximum number of calls to Secret by Query = 1 |
5 |
Partially correct |
478 ms |
8268 KB |
Output isn't correct - number of calls to Secret by Init = 8991, maximum number of calls to Secret by Query = 1 |
6 |
Partially correct |
448 ms |
8328 KB |
Output isn't correct - number of calls to Secret by Init = 8991, maximum number of calls to Secret by Query = 1 |
7 |
Partially correct |
452 ms |
8456 KB |
Output isn't correct - number of calls to Secret by Init = 8991, maximum number of calls to Secret by Query = 1 |
8 |
Partially correct |
448 ms |
8456 KB |
Output isn't correct - number of calls to Secret by Init = 8991, maximum number of calls to Secret by Query = 1 |
9 |
Partially correct |
449 ms |
8324 KB |
Output isn't correct - number of calls to Secret by Init = 8991, maximum number of calls to Secret by Query = 1 |
10 |
Partially correct |
442 ms |
8364 KB |
Output isn't correct - number of calls to Secret by Init = 8991, maximum number of calls to Secret by Query = 1 |