233.トロミノ
24306 ワード
白駿
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)
Reference
この問題について(233.トロミノ), 我々は、より多くの情報をここで見つけました https://velog.io/@corone_hi/233テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol