-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1018.py
More file actions
25 lines (23 loc) · 790 Bytes
/
1018.py
File metadata and controls
25 lines (23 loc) · 790 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
N, M = map(int, input().split())
data = [list(input()) for _ in range(N)]
result = []
for i in range(N):
for j in range(M):
if (i+7 < N) and (j+7 < M):
count1 = 0
count2 = 0
for a in range(i, i+8):
for b in range(j, j+8):
if (a + b) % 2 == 0:
if data[a][b] != 'B':
count1 += 1
elif data[a][b] != 'W':
count2 += 1
else:
if data[a][b] != 'W':
count1 += 1
elif data[a][b] != 'B':
count2 += 1
result.append(count1)
result.append(count2)
print(min(result))