Skip to content

Commit

Permalink
solve : 1018 체스판 다시 칠하기
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed Apr 30, 2024
1 parent 95b633a commit de7bbbc
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions python/boj_1018.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import sys

input = sys.stdin.readline


def solution(n, m, data):
answer = 1e9

for a in range(n - 7):
for b in range(m - 7):
index1 = 0
index2 = 0

for i in range(a, a + 8):
for j in range(b, b + 8):
if (i + j) % 2 == 0:
if data[i][j] != 'W':
index1 += 1
if data[i][j] != 'B':
index2 += 1
else:
if data[i][j] != 'B':
index1 += 1
if data[i][j] != 'W':
index2 += 1

answer = min(answer, index1, index2)

return answer


def display_result(answer):
print(answer)


def main():
n, m = map(int, input().split())
data = [list(map(str, input().rstrip())) for _ in range(n)]
answer = solution(n, m, data)
display_result(answer)


main()

0 comments on commit de7bbbc

Please sign in to comment.