# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
944483 | rainboy | 토마토 (KOI13_tomato) | C11 | 72 ms | 10628 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define N 1000
#define M 1000
#define INF 0x3f3f3f3f
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int main() {
static int aa[N][M], dd[N][M];
int n, m, i, j, d;
scanf("%d%d", &m, &n);
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
scanf("%d", &aa[i][j]);
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
dd[i][j] = aa[i][j] == 1 ? 0 : INF;
for (i = 0; i < n; i++) {
for (j = 1; j < m; j++)
dd[i][j] = min(dd[i][j], dd[i][j - 1] + 1);
for (j = m - 2; j >= 0; j--)
dd[i][j] = min(dd[i][j], dd[i][j + 1] + 1);
}
for (j = 0; j < m; j++) {
for (i = 1; i < n; i++)
dd[i][j] = min(dd[i][j], dd[i - 1][j] + 1);
for (i = n - 2; i >= 0; i--)
dd[i][j] = min(dd[i][j], dd[i + 1][j] + 1);
}
d = 0;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
d = max(d, dd[i][j]);
if (d == INF)
d = -1;
printf("%d\n", d);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |