[๋ฐฑ์ค-14500] ํ
ํธ๋ก๋ฏธ๋
ธ / Python
๐ Problem Solving/Baekjoon
import sys
input = sys.stdin.readline
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 func(x, y):
global answer
for i in range(19):
result = 0
cnt = 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]
cnt += 1
if cnt == 4:
answer = max(answer, result)
for i in range(n):
for j in range(m):
func(i, j)
print(answer)
ํด์ค
๋ง๋ค์ด์ง ์ ์๋ ๋ชจ๋ ๋ํ์ ์ขํ๋ฅผ ์ ์ฅํ ๋ฆฌ์คํธ๋ฅผ ๋ฐ๋ก ๋ง๋ค์๋ค.
๊ฐ์ด ๋ค์ด์๋ ์ขํ์ ๋ฏธ๋ฆฌ ๋ง๋ค์ด ๋ ๋ํ์ ์ขํ๋ฅผ ๋ํด๊ฐ๋ฉฐ ๋ค ์นธ์ด ๋ชจ๋ ๋ฒ์ ์์ ์์ ๋ ๊ทธ ํฉ์ ๊ตฌํด์ค๋ค.
'๐ Problem Solving > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค-1991] ํธ๋ฆฌ ์ํ / Python (0) | 2021.06.01 |
---|---|
[๋ฐฑ์ค-16236] ์๊ธฐ ์์ด / Python (0) | 2021.05.31 |
[๋ฐฑ์ค-10026] ์ ๋ก์์ฝ / Python (0) | 2021.05.31 |
[๋ฐฑ์ค-11727] 2xn ํ์ผ๋ง 2 / Python (0) | 2021.05.30 |
[๋ฐฑ์ค-11726] 2xn ํ์ผ๋ง / Python (0) | 2021.05.30 |