-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex03h1_square.py
70 lines (56 loc) · 1.07 KB
/
ex03h1_square.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import sys
input = sys.stdin.readline
print = lambda s:sys.stdout.write(str(s)+"\n")
sys.setrecursionlimit(200000)
n,m = [int(i) for i in input().split()]
M = []*n
for i in range(n):
if m==0:
continue
mini = str(input().strip())
M.append( [int(j) for j in mini] )
MM = [ [0]*(m+1) for i in range(n+1) ]
maxi = 0
for i in range(1,n+1):
for j in range(1,m+1):
'''
if MM[i-1][j-1] == MM[i-1][j] and MM[i-1][j-1] == MM[i][j-1] and M[i-1][j-1] == 1:
MM[i][j] = MM[i-1][j-1]+1
if MM[i][j] > maxi:
maxi = MM[i][j]
elif M[i-1][j-1] == 1:
MM[i][j] = max( MM[i-1][j-1],MM[i][j-1],MM[i-1][j] )
else:
MM[i][j] = 0
'''
if M[i-1][j-1]==0:
MM[i][j] = 0
else:
MM[i][j] = min( MM[i-1][j-1],MM[i][j-1],MM[i-1][j] )+1
maxi = max(maxi,MM[i][j])
print(maxi)
#print(MM)
'''
5 5
00010
01111
00111
00111
00111
5 5
00010
01111
00110
00110
00000
1 10
1111111011
7 5
11110
11110
11110
11110
01111
01111
01111
'''