233. 테트로미노

아현·2021년 8월 3일
0

Algorithm

목록 보기
243/400

백준



1.Python



n, m = map(int, input().split())
board = [list(map(int, input().split())) for _ in range(n)]

tetromino = [
    [(0,0), (0,1), (1,0), (1,1)], 
    [(0,0), (0,1), (0,2), (0,3)], 
    [(0,0), (1,0), (2,0), (3,0)],
    [(0,0), (0,1), (0,2), (1,0)], 
    [(1,0), (1,1), (1,2), (0,2)],
    [(0,0), (1,0), (1,1), (1,2)], 
    [(0,0), (0,1), (0,2), (1,2)], 
    [(0,0), (1,0), (2,0), (2,1)],
    [(2,0), (2,1), (1,1), (0,1)],
    [(0,0), (0,1), (1,0), (2,0)], 
    [(0,0), (0,1), (1,1), (2,1)],
    [(0,0), (0,1), (0,2), (1,1)], 
    [(1,0), (1,1), (1,2), (0,1)], 
    [(0,0), (1,0), (2,0), (1,1)], 
    [(1,0), (0,1), (1,1), (2,1)],
    [(1,0), (2,0), (0,1), (1,1)],
    [(0,0), (1,0), (1,1), (2,1)],
    [(1,0), (0,1), (1,1), (0,2)],
    [(0,0), (0,1), (1,1), (1,2)]
]

answer = 0

def find(x, y):
    global answer
    for i in range(19):
        result = 0 
        for j in range(4): 
            nx = x+tetromino[i][j][0] 
            ny = y+tetromino[i][j][1] 
            if 0 <= nx < n and 0 <= ny < m:
                result += board[nx][ny] 
            
        answer = max(answer, result) 

for i in range (n):
        for j in range(m):
            find(i, j)

print(answer)
profile
For the sake of someone who studies computer science

0개의 댓글