Submission #255879

#TimeUsernameProblemLanguageResultExecution timeMemory
255879IOrtroiiiSecret (JOI14_secret)C++14
100 / 100
520 ms8460 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; int A[1010]; int dp[1010][1010]; void gen(int l, int r) { if (l == r) { dp[l][r] = A[l]; return; } int md = (l + r) >> 1; gen(l, md); gen(md + 1, r); for (int i = md - 1; i >= l; --i) dp[i][md] = Secret(A[i], dp[i + 1][md]); for (int i = md + 2; i <= r; ++i) dp[md + 1][i] = Secret(dp[md + 1][i - 1], A[i]); } void Init(int N, int _A[]) { for (int i = 0; i < N; ++i) A[i] = _A[i]; memset(dp, -1, sizeof dp); gen(0, N - 1); } int Query(int l, int r) { if (l == r) return A[l]; for (int md = l; md < r; ++md) { if (dp[l][md] >= 0 && dp[md + 1][r] >= 0) { return Secret(dp[l][md], dp[md + 1][r]); } } }

Compilation message (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...