백준

백준 14500번: 테트로미노

14500번: 테트로미노 (acmicpc.net)

 

14500번: 테트로미노

폴리오미노란 크기가 1×1인 정사각형을 여러 개 이어서 붙인 도형이며, 다음과 같은 조건을 만족해야 한다. 정사각형은 서로 겹치면 안 된다. 도형은 모두 연결되어 있어야 한다. 정사각형의 변

www.acmicpc.net

n,m = map(int, input().split())
tetromino = []
result = []
sum = 0
for i in range(n):
    tetromino.append(list(map(int, input().split())))

#1
for i in range(n-1):
    for j in range(m-2):
        sum=tetromino[i][j]+tetromino[i+1][j]+tetromino[i+1][j+1]+tetromino[i+1][j+2]
        result.append(sum)
for i in range(n-2):
    for j in range(m-1):
        sum=tetromino[i][j]+tetromino[i+1][j]+tetromino[i+1][j+1]+tetromino[i+2][j+1]
        result.append(sum)
for i in range(n-2):
    for j in range(m-1):
        sum=tetromino[i][j]+tetromino[i+1][j]+tetromino[i+1][j+1]+tetromino[i+2][j]
        result.append(sum)
for i in range(n-2):
    for j in range(m-1):
        sum=tetromino[i][j]+tetromino[i+1][j]+tetromino[i+2][j]+tetromino[i+2][j+1]
        result.append(sum)
for i in range(n-3):
    for j in range(m):
        sum=tetromino[i][j]+tetromino[i+1][j]+tetromino[i+2][j]+tetromino[i+3][j]
        result.append(sum)

#2
for i in range(n-1):
    for j in range(m-1):
        sum=tetromino[i][j]+tetromino[i][j+1]+tetromino[i+1][j]+tetromino[i+1][j+1]
        result.append(sum)
for i in range(n-2):
    for j in range(m-1):
        sum=tetromino[i][j]+tetromino[i][j+1]+tetromino[i+2][j+1]+tetromino[i+1][j+1]
        result.append(sum)
for i in range(n-1):
    for j in range(m-2):
        sum=tetromino[i][j]+tetromino[i][j+1]+tetromino[i+1][j+2]+tetromino[i+1][j+1]
        result.append(sum)
for i in range(n-1):
    for j in range(m-2):
        sum=tetromino[i][j+1]+tetromino[i+1][j]+tetromino[i+1][j+1]+tetromino[i+1][j+2]
        result.append(sum)
for i in range(n-2):
    for j in range(m-1):
        sum=tetromino[i][j+1]+tetromino[i+1][j]+tetromino[i+1][j+1]+tetromino[i+2][j]
        result.append(sum)
for i in range(n-1):
    for j in range(m-2):
        sum=tetromino[i][j+1]+tetromino[i][j+2]+tetromino[i+1][j]+tetromino[i+1][j+1]
        result.append(sum)
for i in range(n-2):
    for j in range(m-1):
        sum=tetromino[i][j+1]+tetromino[i+1][j]+tetromino[i+1][j+1]+tetromino[i+2][j+1]
        result.append(sum)
for i in range(n-2):
    for j in range(m-1):
        sum=tetromino[i][j]+tetromino[i][j+1]+tetromino[i+1][j]+tetromino[i+2][j]
        result.append(sum)
for i in range(n-2):
    for j in range(m-1):
        sum=tetromino[i][j+1]+tetromino[i+1][j+1]+tetromino[i+2][j]+tetromino[i+2][j+1]
        result.append(sum)

#3
for i in range(n-1):
    for j in range(m-2):
        sum=tetromino[i][j]+tetromino[i][j+1]+tetromino[i][j+2]+tetromino[i+1][j]
        result.append(sum)
for i in range(n-1):
    for j in range(m-2):
        sum=tetromino[i][j]+tetromino[i][j+1]+tetromino[i][j+2]+tetromino[i+1][j+1]
        result.append(sum)
for i in range(n-1):
    for j in range(m-2):
        sum=tetromino[i][j]+tetromino[i][j+1]+tetromino[i][j+2]+tetromino[i+1][j+2]
        result.append(sum)
for i in range(n-1):
    for j in range(m-2):
        sum=tetromino[i][j+2]+tetromino[i+1][j]+tetromino[i+1][j+1]+tetromino[i+1][j+2]
        result.append(sum)

#4
for i in range(n):
    for j in range(m-3):
        sum=tetromino[i][j]+tetromino[i][j+1]+tetromino[i][j+2]+tetromino[i][j+3]
        result.append(sum)
print(max(result))

'백준' 카테고리의 다른 글

백준 2960번: 에라토스테네스의 체  (0) 2021.07.02
백준 14891번: 톱니바퀴  (0) 2021.07.02
백준 4949번: 균형잡힌 세상  (0) 2021.06.29
백준 11866번: 요세푸스 문제 0  (0) 2021.06.27
백준 4963번: 섬의 개수  (0) 2021.05.20