#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]);
}
if(l < mid) div(l, mid, A);
if(mid + 1 < r) 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
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
123 ms |
6748 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
110 ms |
6992 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
109 ms |
6740 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
391 ms |
8272 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
388 ms |
8288 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
383 ms |
8288 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
411 ms |
8136 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
387 ms |
8272 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
390 ms |
8284 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
390 ms |
8544 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |