Submission #28680

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
286802017-07-16 08:40:04Sorry AcornCkiGuiziTeam (#68)Test Data Creation (FXCUP2_testdata)C++14
1 / 1
589 ms219152 KiB
·#include <cstdio>
#include <algorithm>
using namespace std;
int a[90009];
int b[90009];
int d[303][303][606];
int main() {
int ti, tj;
int i, j, k, l, m, n, t;
scanf("%d%d", &m, &n);
for (i = 0; i < n * m; i++) scanf("%d", &a[i]);
for (i = 0; i < n; i++) for (j = 0; j < m; j++) for (k = 0; k <= 600; k++) d[i][j][k] = 2e9;
d[0][0][0] = 0;
for (i = 0; i < n; i++) for (j = 0; j < m; j++) for (k = 0; k <= 600; k++) {
t = i * m + j + k;
ti = t / n;
tj = t % n;
if (k) t = d[i][j][k] + a[i * m + j];
else t = d[i][j][k];
if (i + 1 < n && k >= m) d[i + 1][j][k - m] = min(d[i + 1][j][k - m], t);
if (j + 1 < m && k) d[i][j + 1][k - 1] = min(d[i][j + 1][k - 1], t);
if (k) t = d[i][j][k] + a[ti * n + tj];
else t = d[i][j][k];
if (ti + 1 < m && k + n <= 600) d[i][j][k + n] = min(d[i][j][k + n], t);
if (tj + 1 < n && k + 1 <= 600) d[i][j][k + 1] = min(d[i][j][k + 1], t);
}
printf("%d\n", d[n - 1][m - 1][0] + a[n * m - 1]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

testdata.cpp: In function 'int main()':
testdata.cpp:12:15: warning: unused variable 'l' [-Wunused-variable]
  int i, j, k, l, m, n, t;
               ^
testdata.cpp:13: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:14: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...