# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28452 | 2017-07-16T06:05:13 Z | Sorry AcornCkiGuiziTeam(#1226, gs13068) | Test Data Creation (FXCUP2_testdata) | C++14 | 189 ms | 219152 KB |
#include <cstdio> #include <algorithm> using namespace std; int a[90009]; int b[90009]; int d[606][303][303]; int main() { int i, j, k, l, m, n, t; scanf("%d%d", &m, &n); for (i = 0; i < n * m; i++) scanf("%d", &a[i]); d[0][0][0] = a[0]; for (i = 1; i <= n + m - 2; i++) for (j = max(0, i - m + 1); j <= i && j < n; j++) for (k = max(0, i - n + 1); k <= i && k < m; k++) { t = 2e9; if (j && k) t = min(t, d[i - 1][j - 1][k - 1]); if (i - j && k) t = min(t, d[i - 1][j][k - 1]); if (j && i - k) t = min(t, d[i - 1][j - 1][k]); if (i - j && i - k) t = min(t, d[i - 1][j][k]); if (j * m + i - j == k * n + i - k) t += a[j * m + i - j]; else t += a[j * m + i - j] + a[k * n + i - k]; d[i][j][k] = t; } printf("%d\n", d[n + m - 2][n - 1][m - 1]); i = n + m - 2; j = n - 1; k = m - 1; while (i) { b[j * m + i - j] = b[k * n + i - k] = 1; t = d[i][j][k]; if (j * m + i - j == k * n + i - k) t -= a[j * m + i - j]; else t -= a[j * m + i - j] + a[k * n + i - k]; i--; if (j && k && t == d[i][j - 1][k - 1]) { j--; k--; continue; } if (i - j && k && t == d[i][j][k - 1]) { k--; continue; } if (j && i - k && t == d[i][j - 1][k]) { j--; continue; } } b[0] = 1; for (i = 0; i < n; i++, puts("")) for (j = 0; j < m; j++) printf("%d ", b[i * m + j]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 219152 KB | Correct |
2 | Correct | 0 ms | 219152 KB | Correct |
3 | Correct | 0 ms | 219152 KB | Correct |
4 | Correct | 0 ms | 219152 KB | Correct |
5 | Correct | 29 ms | 219152 KB | Correct |
6 | Correct | 189 ms | 219152 KB | Correct |
7 | Correct | 113 ms | 219152 KB | Correct |
8 | Correct | 0 ms | 219152 KB | Correct |
9 | Correct | 0 ms | 219152 KB | Correct |
10 | Correct | 0 ms | 219152 KB | Correct |
11 | Incorrect | 0 ms | 219152 KB | Wrong |
12 | Halted | 0 ms | 0 KB | - |