-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposhykplpr.py
60 lines (51 loc) · 900 Bytes
/
poshykplpr.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
n=0
smax=0
s=0
def ostriv(a,x,y,k,s):
a[x][y]=k;
s[0]=s[0]+1
if a[x-1][y]=='*':
s=ostriv(a,x-1,y,k,s)
else:
s[1]=s[1]+1
if a[x+1][y]=='*':
s=ostriv(a,x+1,y,k,s)
else:
s[1]=s[1]+1
if a[x][y-1]=='*':
s=ostriv(a,x,y-1,k,s)
else:
s[1]=s[1]+1
if a[x][y+1]=='*':
s=ostriv(a,x,y+1,k,s)
else:
s[1]=s[1]+1
return s
n=int(input())
a=[]
k=0
for i in range(n+2):
a.append([0]*(n+2))
s=[]
for i in range(1,n+1):
s=input()
for j in range(0,n):
a[i][j+1]=s[j]
for i in range(1,n+1):
print("")
for j in range(1,n+1):
print(a[i][j],end="")
for i in range(1,n+1):
for j in range(1,n+1):
if a[i][j]=="*":
k+=1
s=[0,0]
s=ostriv(a,i,j,k,s)
if s[0]>smax:
smax=s[0]
pmax=s[1]
print(smax," ",pmax)
for i in range(1,n+1):
print("")
for j in range(1,n+1):
print(a[i][j],end="")