# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1040875 | 2024-08-01T11:17:07 Z | lovrot | 건포도 (IOI09_raisins) | C++17 | 70 ms | 52252 KB |
#include <cstdio> #include <cstring> #include <algorithm> #define debug(...) fprintf(stderr, __VA_ARGS__) using namespace std; typedef long long ll; const int N = 51; const ll OO = 0x7FFFFFFFFFFFFFFF; int n, m; ll sum[N][N]; ll dp[N][N][N][N]; int main() { scanf("%d%d", &n, &m); for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { scanf("%lld", &sum[i][j]); sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1]; } } for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { dp[i][j][i][j] = 0; for(int k = i; k > 0; --k) { for(int l = j - (k == i); l > 0; --l) { ll &d = dp[i][j][k][l] = OO; for(int x = k; x < i; ++x) { d = min(d, dp[i][j][x + 1][l] + dp[x][j][k][l]); } for(int y = l; y < j; ++y) { d = min(d, dp[i][j][k][y + 1] + dp[i][y][k][l]); } d += sum[i][j] - sum[i][l - 1] - sum[k - 1][l] + sum[k - 1][l - 1]; // printf("%d %d %d %d : %d\n", i, j, k, l, dp[i][j][k][l]); } } } } printf("%lld\n", dp[n][m][2][1]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
3 | Incorrect | 0 ms | 6492 KB | Output isn't correct |
4 | Incorrect | 0 ms | 4444 KB | Output isn't correct |
5 | Incorrect | 1 ms | 8540 KB | Output isn't correct |
6 | Incorrect | 1 ms | 10584 KB | Output isn't correct |
7 | Incorrect | 1 ms | 16732 KB | Output isn't correct |
8 | Incorrect | 2 ms | 18780 KB | Output isn't correct |
9 | Incorrect | 3 ms | 24924 KB | Output isn't correct |
10 | Incorrect | 4 ms | 26972 KB | Output isn't correct |
11 | Incorrect | 3 ms | 20828 KB | Output isn't correct |
12 | Incorrect | 8 ms | 33116 KB | Output isn't correct |
13 | Incorrect | 10 ms | 37212 KB | Output isn't correct |
14 | Incorrect | 4 ms | 23024 KB | Output isn't correct |
15 | Incorrect | 12 ms | 39508 KB | Output isn't correct |
16 | Incorrect | 4 ms | 41308 KB | Output isn't correct |
17 | Incorrect | 7 ms | 43356 KB | Output isn't correct |
18 | Incorrect | 30 ms | 49676 KB | Output isn't correct |
19 | Incorrect | 49 ms | 51732 KB | Output isn't correct |
20 | Incorrect | 70 ms | 52252 KB | Output isn't correct |