Submission #1110766

#TimeUsernameProblemLanguageResultExecution timeMemory
1110766Alihan_8Secret (JOI14_secret)C++17
0 / 100
313 ms8460 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; int qry(int a, int b){ return Secret(a, b); } vector <vector<int>> dp; int n; void Init(int N, int A[]) { n = N; dp.resize(n); for ( auto &u: dp ) u.resize(n); auto dnc = [&](auto dnc, int l, int r) -> void{ if ( l > r ) return; if ( l == r ){ dp[l][l] = A[l]; return; } int m = (l + r) / 2; dp[m][m] = A[m], dp[m + 1][m + 1] = A[m + 1]; for ( int i = m - 1; i >= l; i-- ){ dp[m][i] = qry(dp[m][i + 1], A[i]); } for ( int i = m + 2; i <= r; i++ ){ dp[m + 1][i] = qry(dp[m + 1][i - 1], A[i]); } dnc(dnc, l, m - 1); dnc(dnc, m + 1, r); }; dnc(dnc, 0, n - 1); } int Query(int L, int R) { if ( L == R ) return dp[L][R]; int a = 0, b = n - 1; while ( true ){ int m = (a + b) / 2; if ( L <= m && R > m ) return qry(dp[m][L], dp[m + 1][R]); else if ( R == m ) return dp[m][L]; else if ( L == m + 1 ) return dp[m + 1][R]; else if ( m > R ) b = m - 1; else a = m; } }
#Verdict Execution timeMemoryGrader output
Fetching results...