From f8541f3578f2b91710ac93ebaa7a1c61dffa9630 Mon Sep 17 00:00:00 2001 From: hangyeol Date: Mon, 2 Jun 2025 22:09:29 +0900 Subject: [PATCH 1/2] =?UTF-8?q?121=EC=B0=A8=201=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4=20(=EC=B0=B8=EA=B3=A0..)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\261\355\225\234\352\262\260.py" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "live12/test121/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" diff --git "a/live12/test121/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" "b/live12/test121/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" new file mode 100644 index 00000000..0f939b53 --- /dev/null +++ "b/live12/test121/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,49 @@ +import sys + +def main(): + input = sys.stdin.readline + + N, M, K = map(int, input().split()) + + board = [input().strip() for _ in range(N)] + + w = [[0] * M for _ in range(N)] + b = [[0] * M for _ in range(N)] + + for i in range(N): + for j in range(M): + expectedColorIfWhite = 'W' if (i + j) % 2 == 0 else 'B' + expectedColorIfBlack = 'B' if (i + j) % 2 == 0 else 'W' + + if board[i][j] != expectedColorIfWhite: + w[i][j] = 1 + if board[i][j] != expectedColorIfBlack: + b[i][j] = 1 + + def prefixSum(array): + ps = [[0] * (M+1) for _ in range(N+1)] + + for i in range(N): + for j in range(M): + ps[i+1][j+1] = array[i][j] + ps[i][j+1] + ps[i+1][j] - ps[i][j] + + return ps + + prefixSumWhite = prefixSum(w) + print(prefixSumWhite) + prefixSumBlack = prefixSum(b) + print(prefixSumBlack) + + minRepaintCount = float('inf') + for i in range(N - K + 1): + for j in range(M - K + 1): + x1, y1 = i, j + x2, y2 = i + K, j + K + whiteCount = prefixSumWhite[x2][y2] - prefixSumWhite[x1][y2] - prefixSumWhite[x2][y1] + prefixSumWhite[x1][y1] + blackCount = prefixSumBlack[x2][y2] - prefixSumBlack[x1][y2] - prefixSumBlack[x2][y1] + prefixSumBlack[x1][y1] + minRepaintCount = min(minRepaintCount, whiteCount, blackCount) + + print(minRepaintCount) + +if __name__ == '__main__': + main() \ No newline at end of file From 5a2dbec09868aad59f638031b9afb73e6c14e7be Mon Sep 17 00:00:00 2001 From: hangyeol Date: Mon, 2 Jun 2025 22:10:16 +0900 Subject: [PATCH 2/2] =?UTF-8?q?121=EC=B0=A8=202=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\260\261\355\225\234\352\262\260.py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "live12/test121/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" diff --git "a/live12/test121/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" "b/live12/test121/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" new file mode 100644 index 00000000..f6ec5f50 --- /dev/null +++ "b/live12/test121/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,13 @@ +import sys + +def main(): + input = sys.stdin.readline + + N = int(input()) + heights = list(map(int, input().split())) + + result = 0 + + +if __name__ == '__main__': + main() \ No newline at end of file