#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
int val[1003][1003],arr[1003],n;
void dnq(int l,int r){
if (l == r) return;
int mid = (l + r)/2;
for (int i = mid + 2; i <= r; i++)
val[mid + 1][i] = Secret(val[mid + 1][i - 1],arr[i]);
for (int i = mid - 1; i >= l; i--)
val[i][mid] = Secret(arr[i],val[i + 1][mid]);
dnq(l,mid);
dnq(mid + 1,r);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < N; i++){
val[i][i] = A[i];
arr[i] = A[i];
}
dnq(0,N - 1);
}
int Query(int L, int R) {
if (L == R) return arr[L];
int l = 0,r = n - 1;
while (1){
int mid = (l + r)/2;
if (L <= mid && mid < R)
return Secret(val[L][mid],val[mid + 1][R]);
if (R <= mid){
r = mid;
}else{
l = mid + 1;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
123 ms |
6824 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
119 ms |
6828 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
111 ms |
6828 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
420 ms |
8368 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
396 ms |
8260 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
401 ms |
8372 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
424 ms |
8368 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
422 ms |
8364 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
427 ms |
8360 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
395 ms |
8364 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |