Submission #944483

#TimeUsernameProblemLanguageResultExecution timeMemory
944483rainboy토마토 (KOI13_tomato)C11
4.80 / 16
72 ms10628 KiB
#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)

tomato.c: In function 'main':
tomato.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d", &m, &n);
      |  ^~~~~~~~~~~~~~~~~~~~~
tomato.c:17:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |    scanf("%d", &aa[i][j]);
      |    ^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...