-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj-1018.py
More file actions
25 lines (23 loc) · 720 Bytes
/
boj-1018.py
File metadata and controls
25 lines (23 loc) · 720 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
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
chess = [input().strip() for _ in range(n)]
ans = []
for i in range(n-7):
for j in range(m-7):
sww = 0 #start with white
swb = 0 #start with black
for k in range(i, i+8):
for l in range(j, j+8):
if (k + l) % 2 == 0:
if chess[k][l] != 'W':
sww += 1
if chess[k][l] != 'B':
swb += 1
else:
if chess[k][l] != 'B':
sww += 1
if chess[k][l] != 'W':
swb += 1
ans.append(min(sww, swb))
print(min(ans))