# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
738213 | onebit1024 | Secret (JOI14_secret) | C++17 | 439 ms | 24472 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>dp,comp;
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]),comp[i][m] =1;
for(int i = m+2;i<=r;++i)dp[m+1][i] = Secret(dp[m+1][i-1],a[i]),comp[m+1][i] = 1;
recur(l,m-1,a);
recur(m+1,r,a);
}
void Init(int N, int A[]) {
dp = vector<vector<int>>(N, vector<int>(N,0));
comp = vector<vector<int>>(N, vector<int>(N,0));
vector<int>a;
for(int i = 0;i<N;++i)dp[i][i] = A[i],a.push_back(A[i]),comp[i][i] = 1;
recur(0,N-1,a);
}
int Query(int L, int R) {
for(int i = L;i<=R;++i){
if(comp[L][i] && comp[i+1][R]){
return Secret(dp[L][i],dp[i+1][R]);
}
}
return dp[L][R];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |