#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 20
#define MAXN 200005
int ranges[1005][1005];
int n;
void build(int l, int r, int A[]) {
if (l > r)
return ;
int mid1 = (l+r)/2;
int mid2 = mid1+1;
ranges[mid1][mid1] = A[mid1];
ranges[mid2][mid2] = A[mid2];
for (int i = mid1-1; i >= 0; i--)
ranges[i][mid1] = Secret(A[i], ranges[i+1][mid1]);
for (int i = mid2+1; i <= r; i++)
ranges[mid2][i] = Secret(ranges[mid2][i-1], A[i]);
build(l, mid1, A);
build(mid2, r, A);
}
void Init(int N, int A[]) {
build(0, N-1, A);
n = N;
}
int Query(int L, int R) {
int now_l = 0;
int now_r = n-1;
while (now_l <= now_r) {
int mid1 = (now_l+now_r)/2;
int mid2 = (now_l+now_r)/2+1;
if (L <= mid1 && R >= mid2)
return Secret(ranges[L][mid1], ranges[mid2][R]);
if (R <= mid1)
now_r = mid1;
else
now_l = mid2;
}
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
49 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
324 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Runtime error |
305 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Runtime error |
302 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Runtime error |
581 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Runtime error |
581 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Runtime error |
575 ms |
524288 KB |
Execution killed with signal 9 |
7 |
Runtime error |
565 ms |
524288 KB |
Execution killed with signal 9 |
8 |
Runtime error |
571 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Runtime error |
561 ms |
524288 KB |
Execution killed with signal 9 |
10 |
Runtime error |
570 ms |
524288 KB |
Execution killed with signal 9 |