답안 #1067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067 2013-06-23T02:11:50 Z tncks0121 토마토 (KOI13_tomato) C++
16 / 16
128 ms 16792 KB
#include <stdio.h>
FILE *in=stdin;
FILE *out=stdout;
int m, n, h;
int map[1005][1005], cnt[1005][1005], chk;
int q[1000050][2], f, r;
int x, y, dab;
int dx[4] = {-1, 1, 0, 0,};
int dy[4] = {0, 0, -1, 1,};
int main() {
int i, j, l, k;
fscanf(in, "%d%d", &m, &n);
for (j=0;j<=n+1;j++) {
for (l=0;l<=m+1;l++) {
map[j][l] = -1;
cnt[j][l] = 0;
}
}
f=r=0;
for (j=1;j<=n;j++) {
for (l=1;l<=m;l++) {
fscanf(in, "%d", &map[j][l]);
if (map[j][l] == 1)
{
q[r][0]=j;
q[r][1]=l;
r++;
}
}
}
while (f<r) {
x = q[f][0];
y = q[f][1];
f++;
for (k=0;k<4;k++) {
if (map[x+dx[k]][y+dy[k]] == 0)
{
map[x+dx[k]][y+dy[k]] = 1;
cnt[x+dx[k]][y+dy[k]] = cnt[x][y] + 1;
q[r][0]=x+dx[k];
q[r][1]=y+dy[k];
r++;
}
}
}
dab=0;
chk = 0;
for (j=1;j<=n;j++) {
for (l=1;l<=m;l++) {
if (dab < cnt[j][l])
dab = cnt[j][l];
if (map[j][l] == 0)
chk = 1;
}
}
  if (chk == 1) fprintf(out, "-1\n");
else fprintf(out, "%d\n", dab);
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 16792 KB Output is correct
2 Correct 0 ms 16792 KB Output is correct
3 Correct 0 ms 16792 KB Output is correct
4 Correct 0 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 16792 KB Output is correct
2 Correct 0 ms 16792 KB Output is correct
3 Correct 0 ms 16792 KB Output is correct
4 Correct 0 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 16792 KB Output is correct
2 Correct 0 ms 16792 KB Output is correct
3 Correct 0 ms 16792 KB Output is correct
4 Correct 0 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16792 KB Output is correct
2 Correct 4 ms 16792 KB Output is correct
3 Correct 0 ms 16792 KB Output is correct
4 Correct 0 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16792 KB Output is correct
2 Correct 0 ms 16792 KB Output is correct
3 Correct 0 ms 16792 KB Output is correct
4 Correct 0 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 16792 KB Output is correct
2 Correct 4 ms 16792 KB Output is correct
3 Correct 0 ms 16792 KB Output is correct
4 Correct 4 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 16792 KB Output is correct
2 Correct 24 ms 16792 KB Output is correct
3 Correct 12 ms 16792 KB Output is correct
4 Correct 12 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 16792 KB Output is correct
2 Correct 44 ms 16792 KB Output is correct
3 Correct 8 ms 16792 KB Output is correct
4 Correct 8 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 16792 KB Output is correct
2 Correct 96 ms 16792 KB Output is correct
3 Correct 12 ms 16792 KB Output is correct
4 Correct 56 ms 16792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 16792 KB Output is correct
2 Correct 128 ms 16792 KB Output is correct
3 Correct 120 ms 16792 KB Output is correct
4 Correct 88 ms 16792 KB Output is correct