Submission #585646

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5856462022-06-29 07:14:50Drew_Raisins (IOI09_raisins)C++17
100 / 100
752 ms27236 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAX = 69;
const int inf = 1e9 + 69;
int N, M;
int pfx[MAX][MAX];
int dp[MAX][MAX][MAX][MAX];
inline int sum(int r1, int c1, int r2, int c2)
{
return pfx[r2][c2] - pfx[r1-1][c2] - pfx[r2][c1-1] + pfx[r1-1][c1-1];
}
inline int solve(int r1, int c1, int r2, int c2)
{
if (r1 == r2 && c1 == c2)
return 0;
if (dp[r1][c1][r2][c2] != inf)
return dp[r1][c1][r2][c2];
for (int i = r1; i < r2; ++i)
dp[r1][c1][r2][c2] = min(dp[r1][c1][r2][c2], sum(r1, c1, r2, c2) + solve(r1, c1, i, c2) + solve(i+1, c1, r2, c2));
for (int i = c1; i < c2; ++i)
dp[r1][c1][r2][c2] = min(dp[r1][c1][r2][c2], sum(r1, c1, r2, c2) + solve(r1, c1, r2, i) + solve(r1, i+1, r2, c2));
return dp[r1][c1][r2][c2];
}
int main()
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...