We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a94e7af commit ef201cdCopy full SHA for ef201cd
YoonYn9915/brute force/2024-10-14-[백준]-1018-체스판 다시 칠하기.py
@@ -0,0 +1,27 @@
1
+n, m = map(int, input().split())
2
+
3
+mtr = []
4
+cnt = []
5
+for i in range(n):
6
+ mtr.append(input())
7
8
+for a in range(n - 7):
9
+ for b in range(m - 7): # 8*8로 자르기 위해, -7해준다
10
+ w_index = 0 # 흰색으로 시작
11
+ b_index = 0 # 검은색으로 시작
12
+ for i in range(a, a + 8): # 시작지점
13
+ for j in range(b, b + 8): # 시작지점
14
+ if (i + j) % 2 == 0: # 짝수인 경우
15
+ if mtr[i][j] != 'W': # W가 아니면, 즉 B이면
16
+ w_index += 1 # W로 칠하는 갯수
17
+ else: # W일 때
18
+ b_index += 1 # B로 칠하는 갯수
19
+ else: # 홀수인 경우
20
21
22
+ else:
23
24
25
+ cnt.append(w_index) # W로 시작할 때 경우의 수
26
+ cnt.append(b_index) # B로 시작할 때 경우의 수
27
+print(min(cnt))
0 commit comments