Submission #28452

#TimeUsernameProblemLanguageResultExecution timeMemory
28452Sorry AcornCkiGuiziTeam (#68)Test Data Creation (FXCUP2_testdata)C++14
0 / 1
189 ms219152 KiB
#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 (stderr)

testdata.cpp: In function 'int main()':
testdata.cpp:11:15: warning: unused variable 'l' [-Wunused-variable]
  int i, j, k, l, m, n, t;
               ^
testdata.cpp:12:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &m, &n);
                       ^
testdata.cpp:13:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 0; i < n * m; i++) scanf("%d", &a[i]);
                                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...