BOJ - 14500 - 테트로미노
Updated:
import sys
block = [
[(0, 1), (1, 0), (1, 1)],
[(0, 1), (0, 2), (0, 3)],
[(1, 0), (2, 0), (3, 0)],
[(0, 1), (0, 2), (1, 0)],
[(0, 1), (0, 2), (-1, 2)],
[(1, 0), (1, 1), (1, 2)],
[(0, 1), (0, 2), (1, 2)],
[(1, 0), (2, 0), (2, 1)],
[(0, 1), (1, 1), (2, 1)],
[(0, 1), (1, 0), (2, 0)],
[(1, 0), (2, 0), (2, -1)],
[(1, 0), (1, 1), (2, 1)],
[(0, 1), (1, 0), (-1, 1)],
[(0, 1), (1, 0), (1, -1)],
[(0, 1), (1, 1), (1, 2)],
[(0, 1), (0, 2), (1, 1)],
[(1, 0), (1, 1), (1, -1)],
[(1, 0), (2, 0), (1, -1)],
[(1, 0), (1, 1), (2, 0)]
]
def solution():
N, M = map(int, sys.stdin.readline().split())
tetromino = []
for _ in range(N):
tetromino.append(list(map(int, sys.stdin.readline().split())))
score = 0
for i in range(N):
for j in range(M):
# Block Loops
for k in range(19):
temp = 0
# Blcok Sub Loops
temp += tetromino[i][j]
for l in range(3):
dx = i + block[k][l][0]
dy = j + block[k][l][1]
if 0 <= dx < N and 0 <= dy < M:
temp += tetromino[dx][dy]
else:
continue
score = max(score, temp)
print(score)
solution()
https://www.acmicpc.net/problem/14500
Leave a comment