#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
int mat[MAXN][MAXN], n;
void divide(int l, int r, int *A) {
if(l == r) {
mat[l][r] = A[l];
return ;
}
int mid = (l + r) / 2;
mat[mid][mid] = A[mid];
for(int i = mid - 1; i >= l; i--) {
mat[i][mid] = Secret(A[i], mat[i + 1][mid]);
}
mat[mid + 1][mid + 1] = A[mid + 1];
for(int i = mid + 2; i <= r; i++) {
mat[mid + 1][i] = Secret(mat[mid + 1][i - 1], A[i]);
}
divide(l, mid, A);
divide(mid + 1, r, A);
}
void Init(int N, int A[]) {
n = N;
divide(0, N - 1, A);
}
int solve(int l, int r, int ql, int qr) {
int mid = (l + r) / 2;
if(ql <= mid && mid < qr) {
return Secret(mat[ql][mid], mat[mid + 1][qr]);
}
if(qr <= mid) {
return solve(l, mid, ql, qr);
}
return solve(mid + 1, r, ql, qr);
}
int Query(int l, int r) {
if(l == r) {
return mat[l][l];
}
return solve(0, n - 1, l, r);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
145 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
143 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
494 ms |
8352 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
500 ms |
8368 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
500 ms |
8316 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
499 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
498 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
500 ms |
8352 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
504 ms |
8520 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |