๋ฐ์ํ
๐ค๋ฌธ์ ํด๊ฒฐ
-
G5 | ์์ ํ์, ๊ตฌํ
5๊ฐ์ง ๋ํ์ ํ์ ์ํค๊ฑฐ๋ ๋์นญ์์ผ์ ๋ง๋ค ์ ์๋ ๊ฐ์ง์๋ 19๊ฐ์ง์ด๋ค.
- ๋ชจ๋ ๋ํ์ ์ขํ(0, 0์ ๊ธฐ์ค์ผ๋ก)๋ฅผ ๋ง๋ ๋ค.
- ์ฃผ์ด์ง 2์ฐจ์ ๋ฆฌ์คํธ๋ฅผ ํ์นธ์ฉ ๋๋ฉด์
- ๊ทธ ์ง์ ์์ 19๊ฐ์ง ๋ํ์ ๊ฒน์ณ์ ์ซ์๋ฅผ ํ์ํ๋ค.
๐ป์์ค ์ฝ๋
import sys
input = sys.stdin.readline
def go_tetromino(x, y):
for tetromino in tetrominos:
sum_tet = 0
for _x, _y in tetromino:
try:
sum_tet += paper[x + _x][y + _y]
except IndexError:
break
else:
result.append(sum_tet)
if __name__ == '__main__':
N, M = map(int, input().split()) # ์ธ๋ก ๊ฐ๋ก
paper = [list(map(int, input().split())) for _ in range(N)]
result = []
tetrominos = [
[(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)],
[(0, 0), (0, 1), (0, 2), (-1, 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)],
[(0, 0), (0, 1), (1, 1), (2, 1)],
[(0, 0), (0, 1), (1, 0), (2, 0)],
[(0, 0), (1, 0), (2, 0), (2, -1)],
[(0, 0), (1, 0), (1, 1), (2, 1)],
[(0, 0), (0, 1), (1, 0), (-1, 1)],
[(0, 0), (0, 1), (1, 0), (1, -1)],
[(0, 0), (0, 1), (1, 1), (1, 2)],
[(0, 0), (0, 1), (0, 2), (1, 1)],
[(0, 0), (1, 0), (1, 1), (1, -1)],
[(0, 0), (1, 0), (2, 0), (1, -1)],
[(0, 0), (1, 0), (1, 1), (2, 0)]
]
for i in range(N):
for j in range(M):
go_tetromino(i, j)
print(max(result))
๐๋ฌธ์ ํ์ธ
์ถ์ฒ: BACKJOON ONLINE JUDGE
๋งํฌ: https://www.acmicpc.net/problem/14500
๋ฐ์ํ
'Algorithm Problem > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[python] SWEA - 10570. ์ ๊ณฑ ํฐ๋ฆฐ๋๋กฌ ์ (0) | 2020.11.19 |
---|---|
[python] ๋ฐฑ์ค - 15685. ๋๋๊ณค ์ปค๋ธ (์ผ์ฑ SW ์ญ๋ ํ ์คํธ ๊ธฐ์ถ ๋ฌธ์ ) (0) | 2020.11.17 |
[python] ๋ฐฑ์ค - 1261. ์๊ณ ์คํ (0) | 2020.11.15 |
[python] ๋ฐฑ์ค - 14889. ์คํํธ์ ๋งํฌ (0) | 2020.11.14 |
[python] SWEA - 10726. ์ด์ง์ ํํ (2) | 2020.11.13 |