Skip to content

Commit 7218b85

Browse files
committed
120번 1번 문제풀이(시간초과..)
1 parent 099026d commit 7218b85

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n, m, k = map(int, input().split())
6+
board = []
7+
for _ in range(n):
8+
board.append(list(map(str, input().rstrip())))
9+
10+
cnt = []
11+
for a in range(n - k + 1):
12+
for b in range(m - k + 1):
13+
white = 0
14+
black = 0
15+
for i in range(a, a + k):
16+
for j in range(b, b + k):
17+
# 처음 색과 같아야 하는 부분
18+
if (i + j) % 2 == 0:
19+
if board[i][j] != 'W':
20+
white += 1
21+
else:
22+
black += 1
23+
# 처음 색과 달라야 하는 부분
24+
else:
25+
if board[i][j] != 'W':
26+
black += 1
27+
else:
28+
white += 1
29+
cnt.append(white)
30+
cnt.append(black)
31+
print(min(cnt))

0 commit comments

Comments
 (0)