#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>dp;
void recur(int l, int r,vector<int>&a){
if(l >= r)return;
int m = (l+r)/2;
for(int i = m-1;i>=l;--i)dp[i][m] = Secret(a[i],dp[i+1][m]);
for(int i = m+2;i<=r;++i)dp[m+1][i] = Secret(dp[m+1][i-1],a[i]);
recur(l,m-1,a);
recur(m+1,r,a);
}
void Init(int N, int A[]) {
dp = vector<vector<int>>(N, vector<int>(N,-1e9));
vector<int>a;
for(int i = 0;i<N;++i)dp[i][i] = A[i],a.push_back(A[i]);
recur(0,N-1,a);
}
int Query(int L, int R) {
for(int i = L;i<=R;++i){
if(dp[L][i]!=-1e9 && dp[i+1][R]!=-1e9){
return Secret(dp[L][i],dp[i+1][R]);
}
}
return dp[L][R];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
123 ms |
3404 KB |
Output is correct - number of calls to Secret by Init = 3331, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
122 ms |
3328 KB |
Output is correct - number of calls to Secret by Init = 3339, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
123 ms |
3560 KB |
Output is correct - number of calls to Secret by Init = 3347, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
439 ms |
8140 KB |
Output is correct - number of calls to Secret by Init = 7467, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
424 ms |
8276 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
6 |
Runtime error |
425 ms |
16588 KB |
Execution killed with signal 11 |
7 |
Correct |
427 ms |
8236 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
427 ms |
8252 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
436 ms |
8180 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
430 ms |
8224 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |