#include "secret.h"
const int mxn = 100;
int n, range[mxn][mxn];
void build(int l, int r, int a[]) {
if(l == r) return;
// cout << "building: " << l << ' ' << r << '\n';
int m = (l + r) / 2;
int M = (l + r) / 2 + 1;
// cout << " > " << m << ' ' << M << '\n';
range[m][m] = a[m];
range[M][M] = a[M];
for(int i = M + 1; i <= r; i++)
range[M][i] = Secret(range[M][i - 1], a[i]);
for(int i = m - 1; i >= l; i--)
range[i][m] = Secret(a[i], range[i + 1][m]);
build(l, m, a);
build(M, r, a);
}
void Init(int n, int a[]) {
::n = n;
build(0, n - 1, a);
}
int Query(int L, int R) {
int l = 0, r = n - 1;
// cout << "e " << L << ' ' << R << '\n';
// cout << range[L][R] << '\n';
while(r - l > 1) {
int m = (l + r) / 2;
int M = (l + r) / 2 + 1;
// cout << "finding: " << l << ' ' << r << '\n';
// cout << " > " << m << ' ' << M << '\n';
if(L <= m && M <= R) {
// cout << " " << range[L][m] << ' ' << range[M][R] << '\n';
return Secret(range[L][m], range[M][R]);
}
if(R <= m) r = m;
if(M <= L) l = M;
}
// cout << "sussy baka " << range[L][R] << '\n';
return range[L][R];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
112 ms |
4496 KB |
Execution killed with signal 11 |
2 |
Runtime error |
113 ms |
4520 KB |
Execution killed with signal 11 |
3 |
Runtime error |
118 ms |
4584 KB |
Execution killed with signal 11 |
4 |
Runtime error |
423 ms |
8540 KB |
Execution killed with signal 11 |
5 |
Runtime error |
418 ms |
8372 KB |
Execution killed with signal 11 |
6 |
Runtime error |
424 ms |
8784 KB |
Execution killed with signal 11 |
7 |
Runtime error |
417 ms |
8348 KB |
Execution killed with signal 11 |
8 |
Runtime error |
414 ms |
8460 KB |
Execution killed with signal 11 |
9 |
Runtime error |
412 ms |
8428 KB |
Execution killed with signal 11 |
10 |
Runtime error |
410 ms |
8324 KB |
Execution killed with signal 11 |