Submission #1110773

#TimeUsernameProblemLanguageResultExecution timeMemory
1110773Alihan_8Secret (JOI14_secret)C++17
100 / 100
319 ms8368 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{ 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(A[i], dp[m][i + 1]); } for ( int i = m + 2; i <= r; i++ ){ dp[m + 1][i] = qry(dp[m + 1][i - 1], A[i]); } if ( m > l ) dnc(dnc, l, m); if ( m + 1 < r ) 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 ( m < L ) a = m + 1; else b = m; } }
#Verdict Execution timeMemoryGrader output
Fetching results...