Submission #28452

# 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
0 / 1
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

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 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 -