주하진이 각성을 시작하기 시작하는 매우 중요한 사실.1.txt.md.jpeg.tar.gz.

This commit is contained in:
2020-04-30 21:08:08 +09:00
parent a4366d0b35
commit 1d6152084d
4 changed files with 48 additions and 4 deletions

View File

@@ -0,0 +1,32 @@
N, M = map(int, input().split())
T = [input() for i in range(N)]
Min = 10000000000000
for i in range(N-7):
for j in range(M-7):
temp = [t[j:j+8] for t in T[i:i+8]]
start = temp[0][0]
C = 0
ifC = 0
for ki, k in enumerate(range(8)):
for l in range(k+1):
if ki%2 == 0:
C += temp[k-l][l].count("B")
ifC += temp[k-l][l].count("W")
else:
C += temp[k-l][l].count("W")
ifC += temp[k-l][l].count("B")
for ki, k in enumerate(range(7)):
for l in range(k+1):
if ki%2 == 0:
C += temp[l-k+7][7-l] .count("B")
ifC += temp[l-k+7][7-l] .count("W")
else:
C += temp[l-k+7][7-l] .count("W")
ifC += temp[l-k+7][7-l] .count("B")
mine = min(C, ifC)
if mine < Min:
Min = mine
print(Min)