-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj1028.cpp
More file actions
55 lines (45 loc) ยท 801 Bytes
/
boj1028.cpp
File metadata and controls
55 lines (45 loc) ยท 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<stdio.h>
int n, m, ar[777][777], dp[777][777];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
int max(int x, int y)
{
return x > y ? x : y;
}
int min(int x, int y)
{
return x < y ? x : y;
}
int main()
{
scanf("%d %d", &n, &m);
int flag = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
scanf("%1d", &ar[i][j]);
flag = dp[i][j] = ar[i][j];
}
}
if(flag == 0){
printf("0");
return 0;
}
int MAX, ans = 0;
while(1){
MAX = 0;
for(int i = 1; i < n-1; i++){
for(int j = 1; j < m-1; j++){
int now = 777;
for(int k = 0; k < 4; k++){
int nx = i+dx[k];
int ny = j+dy[k];
now = min(now,dp[nx][ny]);
}
dp[i][j] = now+1;
MAX = max(MAX,dp[i][j]);
}
}
if(MAX == ans) break;
ans = MAX;
}
printf("%d", ans);
}