#include <bits/stdc++.h>
#include "secret.h"
int memo[1000][1000], n;
int build(int l, int r, int A[]){
int m = (l + r) / 2;
memo[m][m] = A[m];
memo[m + 1][m + 1] = A[m + 1];
for(int i = m + 2; i <= r; i++) memo[m + 1][i] = Secret(memo[m + 1][i - 1], A[i]);
for(int i = m - 1; i >= l; i--) memo[m][i] = Secret(memo[m][i + 1], A[i]);
if(l < m) build(l, m, A);
if(m + 1 < r) build(m + 1, 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;
while(l < r){
int m = (l + r) / 2;
if(L <= m && m < R) return Secret(memo[m][L], memo[m + 1][R]);
else if(m == R) return memo[m][L];
else if(m < L) l = m + 1;
else r = m;
}
return memo[l][l];
}
Compilation message
secret.cpp: In function 'int build(int, int, int*)':
secret.cpp:14:1: warning: no return statement in function returning non-void [-Wreturn-type]
14 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
393 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Runtime error |
383 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Runtime error |
383 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Runtime error |
677 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Runtime error |
647 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Runtime error |
647 ms |
524288 KB |
Execution killed with signal 9 |
7 |
Runtime error |
649 ms |
524288 KB |
Execution killed with signal 9 |
8 |
Runtime error |
657 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Runtime error |
650 ms |
524288 KB |
Execution killed with signal 9 |
10 |
Runtime error |
656 ms |
524288 KB |
Execution killed with signal 9 |