#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
// int Secret(int X, int Y);
const int MAXN = 1010;
int block[MAXN][MAXN];
int n;
void div(int l, int r, int A[]){
if(l >= r){
block[l][l] = A[l];
return;
}
int mid = (l + r) / 2;
block[mid][mid] = A[mid];
block[mid + 1][mid + 1] = A[mid + 1];
for(int i = mid - 1; i >= l; i--){
block[mid][i] = Secret(A[i], block[mid][i + 1]);
}
for(int i = mid + 2; i <= r; i++){
block[mid + 1][i] = Secret(block[mid + 1][i - 1], A[i]);
}
div(l, mid, A);
div(mid + 1, r, A);
}
void Init(int N, int A[]){
n = N;
div(0, N - 1, A);
}
int Query(int L, int R){
int l = 0, r = n - 1;
while(l < r){
int mid = (l + r) / 2;
if(L <= mid && mid < R){
return Secret(block[mid][L], block[mid + 1][R]);
}
else if(mid == R){
return block[mid][L];
}
else if(mid < L){
l = mid + 1;
}
else{
r = mid;
}
}
return block[l][l];
}
// by me
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
109 ms |
6508 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
112 ms |
7000 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
123 ms |
6736 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
384 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
390 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
389 ms |
8204 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
384 ms |
8284 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
415 ms |
8528 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
391 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
387 ms |
8284 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |