๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿƒ algorithm/boj

BOJ 17829 - 222-ํ’€๋ง

by HandHand 2021. 3. 8.

๋ฌธ์ œ

๋ฐฑ์ค€ ์˜จ๋ผ์ธ ์ €์ง€ - 17829๋ฒˆ

ํ’€์ด ๊ณผ์ •

๋”ฅ๋Ÿฌ๋‹์—์„œ ์‚ฌ์šฉ๋˜๋Š” ํ’€๋ง ์—ฐ์‚ฐ์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

๋ฌธ์ œ์—์„œ ์ œ์‹œํ•œ ๊ฒƒ๊ณผ ๊ฐ™์ด ๊ฐ ๋‹จ๊ณ„์—์„œ ๊ธธ์ด๊ฐ€ ๋ฐ˜์”ฉ ์ค„์–ด๋“ค๋„๋ก ์—ฐ์‚ฐ์„ ๊ตฌํ˜„ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์ฝ”๋“œ


import sys
import math


N = int(input())
matrix = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]


def pooling(matrix):
    l = len(matrix)
    k = l // 2
    ret = [[0] * k for _ in range(k)]
    nx = 0

    for x in range(0, l, 2):
        ny = 0
        for y in range(0, l, 2):
            window = [matrix[x][y], matrix[x + 1][y], matrix[x][y + 1], matrix[x + 1][y + 1]]
            window.sort(reverse=True)
            ret[nx][ny] = window[1]
            ny += 1
        nx += 1

    return ret


def solution():
    answer = matrix

    for _ in range(int(math.log2(N))):
        answer = pooling(answer)

    return answer[0][0]


print(solution())
๋ฐ˜์‘ํ˜•

'๐Ÿƒ algorithm > boj' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

BOJ 2529 - ๋ถ€๋“ฑํ˜ธ  (0) 2021.03.08
BOJ 1802 - ์ข…์ด ์ ‘๊ธฐ  (0) 2021.03.08
BOJ 13905 - ์„ธ๋ถ€  (0) 2021.03.08
BOJ 2458 - ํ‚ค ์ˆœ์„œ  (0) 2021.03.08
BOJ 18111 - ๋งˆ์ธํฌ๋ž˜ํ”„ํŠธ  (0) 2021.03.08

๐Ÿ’ฌ ๋Œ“๊ธ€