#include <secret.h>
int const nmax = 1000;
//int Secret(int X, int Y)
int dp[1 + nmax][1 + nmax];
int v[1 + nmax];
void compute(int from, int to){
int mid = (from + to) / 2;
compute(from, mid);
compute(mid + 1, to);
for(int i = mid - 1; from <= i; i--){
if(dp[i][mid] == -1)
dp[i][mid] = Secret(v[i], dp[i + 1][mid]);
}
for(int i = mid + 2; i <= to; i++)
if(dp[mid + 1][i] == -1)
dp[mid + 1][i] = Secret(dp[mid + 1][i - 1], v[i]);
}
int n;
void Init(int N, int A[]){
n = N;
for(int i = 0; i < n; i++)
v[i] = A[i];
for(int i = 0;i < N; i++)
for(int j = i; j < N; j++)
dp[i][j] = -1;
for(int i = 0; i < n; i++)
dp[i][i] = v[i];
compute(0, N - 1);
}
int ask(int from, int to, int x, int y){
int mid = (from + to)/ 2;
if(x <= mid && mid + 1 <= y)
return Secret(dp[x][mid], dp[mid + 1][y]);
else {
if(y <= mid)
return ask(from, mid, x, y);
else
return ask(mid + 1, to, x, y);
}
}
int Query(int L, int R) {
return ask(0, n - 1, L, R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
576 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Runtime error |
571 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Runtime error |
572 ms |
524288 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Runtime error |
986 ms |
524288 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
990 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Runtime error |
982 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
980 ms |
524288 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
978 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
981 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
985 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |