-
Notifications
You must be signed in to change notification settings - Fork 0
/
BITMAP.c
56 lines (50 loc) · 894 Bytes
/
BITMAP.c
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
56
#include <stdio.h>
#define INF 999999
int main() {
int test;
scanf("%d", &test);
char str[185][185];
int i,j,k,l;
int min, x, y, flag=0;
int row, col;
while(test--!=0) {
scanf("%d%d", &row, &col);
for(i=0;i<row; i++)
scanf("%s", str[i]);
for(i=0; i<row; i++) {
for(j=0; j<col; j++) {
if(str[i][j]=='1') {
printf("0 ");
}
else {
min=INF;
for(k=0; k<row; k++) {
for(l=0; l<col; l++) {
if(str[k][l]=='1') {
x=i-k;
y=j-l;
if(x<0)
x=x*-1;
if(y<0)
y=y*-1;
x=x+y;
if(min>x)
min=x;
}
if(min==1) {
flag=1;
break;
}
}
if(flag==1) {
flag=0;
break;
}
}
printf("%d ", min);
}
}
printf("\n");
}
}
}