-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1080.py
More file actions
52 lines (40 loc) · 876 Bytes
/
Copy path1080.py
File metadata and controls
52 lines (40 loc) · 876 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
import sys
N, M = sys.stdin.readline().split()
start = []
answer = []
diff = []
for i in range(int(N)):
temp = list(sys.stdin.readline())
start.append(temp[:-1])
for i in range(int(N)):
temp = list(sys.stdin.readline())
answer.append(temp[:-1])
temp2 = []
for j in range(int(M)):
if start[i][j] == temp[j]:
temp2.append('T')
else:
temp2.append('F')
diff.append(temp2)
#print(diff)
count = 0
for i in range(int(N)-2):
for j in range(int(M)-2):
if diff[i][j] == 'F':
count += 1
for x in range(3):
for y in range(3):
if diff[i+x][j+y] == 'F':
diff[i+x][j+y] = 'T'
else:
diff[i+x][j+y] = 'F'
correct = 1
for i in range(int(N)):
for j in range(int(M)):
if diff[i][j] == 'F':
correct = 0
break
if correct == 1:
print(count)
else:
print(-1)