Submission #911162

#TimeUsernameProblemLanguageResultExecution timeMemory
911162blackslexRaisins (IOI09_raisins)C++17
100 / 100
98 ms35332 KiB
#include<bits/stdc++.h> using namespace std; const int N = 55; int n, m, a[N][N], pref[N][N], dp[N][N][N][N]; int main() { scanf("%d %d", &n, &m); for (int ix = 1; ix <= n; ix++) for (int jx = 1; jx <= n; jx++) for (int iy = 1; iy <= m; iy++) for (int jy = 1; jy <= m; jy++) dp[ix][iy][jx][jy] = 1e9; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]), pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + a[i][j], dp[i][j][i][j] = 0; for (int szx = 0; szx <= n; szx++) { for (int szy = 0; szy <= m; szy++) { if (!szx && !szy) continue; for (int lx = 1, rx = lx + szx; rx <= n; lx++, rx++) { for (int ly = 1, ry = ly + szy; ry <= m; ly++, ry++) { for (int kx = lx; kx < rx; kx++) dp[lx][ly][rx][ry] = min(dp[lx][ly][rx][ry], dp[lx][ly][kx][ry] + dp[kx + 1][ly][rx][ry]); for (int ky = ly; ky < ry; ky++) dp[lx][ly][rx][ry] = min(dp[lx][ly][rx][ry], dp[lx][ly][rx][ky] + dp[lx][ky + 1][rx][ry]); dp[lx][ly][rx][ry] += pref[rx][ry] - pref[lx - 1][ry] - pref[rx][ly - 1] + pref[lx - 1][ly - 1]; } } } } printf("%d", dp[1][1][n][m]); }

Compilation message (stderr)

raisins.cpp: In function 'int main()':
raisins.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
raisins.cpp:11:68: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]), pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + a[i][j], dp[i][j][i][j] = 0;
      |                                                               ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...