-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP1_330A.py
52 lines (43 loc) · 920 Bytes
/
P1_330A.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
#################
## Cakeminator ##
#################
def main():
r,c = input().split(" ")
cake = []
eat = 0
eliminate = []
for i in range(int(r)):
row = input()
row = list(row)
cake.append(row)
for i in range(int(r)):
evilstrwbr = 0
for j in range(int(c)):
if(cake[i][j] == 'S'):
evilstrwbr += 1
if(evilstrwbr == 0):
eliminate.append(i)
#eliminating rows
while(len(eliminate) != 0):
indice = eliminate.pop()
del(cake[indice])
eat = eat + int(c)
if not cake:
print(eat)
else:
for i in range(len(cake[0])):
evilstrwbr = 0
for j in range(len(cake)):
if(cake[j][i] == 'S'):
evilstrwbr += 1
if(evilstrwbr == 0):
eliminate.append(i) #collums
#eliminating collumns
while(len(eliminate) != 0):
indice = eliminate.pop()
for i in range(len(cake)):
del(cake[i][indice])
eat = eat + len(cake)
print(eat)
if __name__ == "__main__":
main()