728x90
진짜 무식하게 풀어서 기념으로 포스팅
h, w = map(int, input().split())
data = [list(map(int, input().split())) for x in range(h)]
tetrominos = [
# 항상 자기 자신은 포함
# 길쭉이
[(1,0), (2,0), (3,0)],
[(0,1), (0,2), (0,3)],
[(0,-1), (0,-2), (0,-3)],
[(-1,0), (-2,0), (-3,0)],
# 네모
[(1,0),(1,1),(0,1)],
[(1,0),(1,-1),(0,-1)],
[(-1,0),(-1,-1),(0,-1)],
[(-1,0),(-1,1),(0,1)],
# 주황색
[(0,1),(-1,0),(-2,0)],
[(0,1),(0,2),(1,0)],
[(1,0),(2,0),(0,-1)],
[(0,-1),(0,-2),(-1,0)],
# 주황대칭
[(0,-1),(-1,0),(-2,0)],
[(0,-1),(0,-2),(1,0)],
[(1,0),(2,0),(0,1)],
[(0,1),(0,2),(-1,0)],
# 초록색
[(0,1),(1,1),(-1,0)],
[(0,-1),(-1,0),(-1,1)],
[(0,-1),(-1,-1),(1,0)],
[(1,0),(1,-1),(0,1)],
# 초록대칭
[(0,1),(-1,1),(1,0)],
[(0,-1),(1,0),(1,1)],
[(0,-1),(1,-1),(-1,0)],
[(-1,0),(-1,-1),(0,1)],
# 보라색
[(0,-1),(-1,0),(0,1)],
[(0,1),(-1,0),(1,0)],
[(0,1),(0,-1),(1,0)],
[(-1,0),(1,0),(0,-1)],
]
res = 0
def tetro(i,j):
global res
for tetromino in tetrominos:
tmp = data[i][j]
cnt = 0
for dr, dc in tetromino:
nr = dr + i
nc = dc + j
if 0 <= nr < h and 0 <= nc < w:
tmp += data[nr][nc]
cnt += 1
else:
break
if cnt == 3:
if res < tmp:
res = tmp
for i in range(h):
for j in range(w):
tetro(i, j)
print(res)
'PS > Python' 카테고리의 다른 글
[BOJ_Python] 1991. 트리 순회 (0) | 2021.04.08 |
---|---|
[BOJ_Python] 14499. 주사위 굴리기 (0) | 2021.04.05 |
[BOJ_Python] 3190. 뱀 (0) | 2021.04.05 |
[BOJ_Python] 1744. 수 묶기 (0) | 2021.03.28 |
[BOJ_Python] 12871. 무한 문자열 (0) | 2021.03.28 |
최근댓글