-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
25-SeongHoonC #194
25-SeongHoonC #194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ใ ... ์ ๊ฐ ์ธ์ ๊ต์๊ฐ ๋์์๊น์?
์ ๋ฐฑํธ๋ํน์ผ๋ก ํ์ต๋๋ค :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ์ง์ง ์ฑํ๋ ์ฒ๋ผ ํ๋ ค๋ค๊ฐ...
์ฐจ๋ผ๋ฆฌ ๋ณด๋๋ฅผ ๋๋ฆฌ๋ฉด ์ด๋จ๊น? ํด์ ๊ทธ๋ ๊ฒ ํ์๋๋ฐ ์ง์ง ํ๊ฐ ๋ฐ๋ฐ ๋๋ ๋ฌธ์ ์์ด์..
๊ทผ๋ฐ ์ด์ ๋ณด๋๋ฅผ ๋๋ฆฌ๋ ๊ฒ ๋ณด๋ค ํ์ผ์ ๋๋ฆฌ๋ ๊ฒ์ด ์๊ฐ ๋ณต์ก๋ ๋ ์ด๋์ผ ๋ฏ ํด์.
deepcopy๋ฅผ ๋ฐ๋ฐ์จ์ ๊ทธ๋ฐ์ง python3์ผ๋ก๋ ํต๊ณผ๊ฐ ์๋๊ณ pypy3๋ก๋ง ํต๊ณผ๊ฐ ๋๋ค์..
import sys
from copy import *
def input(): return sys.stdin.readline().rstrip()
N, M = map(int, input().split())
board = []
for _ in range(N):
board.append(list(map(int,input().split())))
answer = 0
def check(board):
global answer
for row in range(N):
for col in range(M):
# ์ฒซ ๋ฒ์งธ ๋ํ
if col <= M-4: answer = max(answer, sum(board[row][col:col+4]))
# ๋ ๋ฒ์งธ ๋ํ
if col <= M-2 and row <= N-2:
temp = sum(board[row][col:col+2])
temp += sum(board[row+1][col:col+2])
answer = max(answer, temp)
# ์ธ ๋ฒ์งธ ๋ํ
if col <= M-2 and row <= N-3:
temp = board[row][col]
temp += board[row+1][col]
temp += sum(board[row+2][col:col+2])
answer = max(answer, temp)
# ๋ค ๋ฒ์งธ ๋ํ
if col <= M-2 and row <= N-3:
temp = board[row][col]
temp += sum(board[row+1][col:col+2])
temp += board[row+2][col+1]
answer = max(answer, temp)
# ๋ค์ฏ ๋ฒ์งธ ๋ํ
if col <= M-3 and row <= N-2:
temp = sum(board[row][col:col+3])
temp += board[row+1][col+1]
answer = max(answer, temp)
for horizontal_reverse in range(2):
for vertical_reverse in range(2):
new_board = deepcopy(board)
if horizontal_reverse == 1:
for row_idx in range(N):
new_board[row_idx] = new_board[row_idx][-1::-1]
if vertical_reverse == 1:
for row_idx in range(int((N-0.1)/2)+1):
for col_idx in range(M):
new_board[row_idx][col_idx], new_board[N-row_idx-1][col_idx] = new_board[N-row_idx-1][col_idx], new_board[row_idx][col_idx]
for rotation_count in range(4):
temp_board = []
if rotation_count == 0: check(new_board)
for i in range(rotation_count):
for inner_col in range(M):
now_col = []
for inner_row in range(N-1,-1,-1):
now_col.append(new_board[inner_row][inner_col])
temp_board.append(now_col)
new_board = temp_board[:]
temp_board.clear()
N, M = M, N
check(new_board)
print(answer)
๊ทผ๋ฐ ์ ์ง ์ด๊ฑฐ๋ง๊ณ ๋ ์ข์ ํ์ด๊ฐ ์์ ๊ฒ ๊ฐ์์ ์์น๋ฅผ ํด๋ดค๋๋ฐ DFS๋ก๋ ํ๋ฆฌ๋ค์ ใ ใทใทใทใท
@9kyo-hwang ๊ฐ์ฒ์ฌ ใ ใทใทใทใท
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ๋ฉฐ์น ๋์ ํํ์ด ์ด ๋ฌธ์ ํ์ด๋ดค๋๋ฐ .. ์ด๋ ต๋ค์ ...
๊ฒฐ๊ตญ ๊ตฌํ๊น์ง๋ ๋ชปํ์ต๋๋ค ใ
ใ
์ ๋ ์ฒ์์ 5๊ฐ์ ํ
ํธ๋ฆฌ์ค๋ฅผ ์ ์ฅํด๋๊ณ , ํ์ , ๋ค์ง์ด ๊ฐ๋ฉด์ dfsํ๋ ค๊ณ ํ๋๋ฐ
๋์ ํ ๊ฐ์ด ์์ค๋๋ผ๊ณ ์.. ๐ญ๐ญ ์ค๊ฐ์ ํ๋ฉด์๋ ์ด๊ฒ ๋ง๋..? ๋ผ๋ ์๊ฐ์ด ๋ค์ด์
๊ทธ๋ฅ ๋ชจ๋ ๊ฒฝ์ฐ์ ์๋ฅผ tetris ๋ก ์ ์ฅํด๋๊ณ ๊บผ๋ด ์ฐ๋ ค๊ณ ํ์ต๋๋ค (์๋ ์ฝ๋์
๋๋ค)
ํ์ง๋ง ๊ฒฐ๊ณผ๋ ์คํจ์๊ตฌ์ ...ใ
...
๊ทธ๋์ ์ฑํ๋ PR + ๊ตํฉ๋ PR + ๋ธ๋ก๊ทธ ๊ธ ๋ณด๋ฉด์ ์ดํดํ์ต๋๋ค
๋ค์์ ๋ค์ ํ๋ฒ ๋ ํ์ด๋ด์ผ๊ฒ ๋ค์ ใ
.ใ
์ข์ ๋ฌธ์ ๊ฐ์ฌํฉ๋๋ค ๐ญ๐๐
import sys
def input(): return sys.stdin.readline().rstrip()
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(N)]
visited = [[0 for _ in range(M)] for _ in range(N)]
polionomino = [[0 for _ in range(M)] for _ in range(N)]
direc = [(1,0),(-1,0),(0,1),(0,-1)]
tetris = [
[(0,0), (0,1), (0,2), (0,3)], [(0,0), (1,0), (2,0), (3,0)], # ใ
ก
[(0,0), (0,1), (1,0), (1,1)], # ใ
[(0,0), (1,0), (2,0), (2,1)], [(0,0), (1,0), (2,0), (2,-1)], # L
[(0,0), (0,1), (0,2), (1,0)], [(0,0), (0,1), (0,2), (1,2)], # L
[(0,0), (1,0), (1,1), (1,2)], [(0,0), (0,1), (1,0), (2,0)], # L
[(1,0), (1,1), (1,2), (0,2)], [(0,0), (0,1), (1,1), (2,1)], # L
[(0,0), (0,1), (1,1), (1,2)], [(0,1), (1,1), (1,0), (2,0)], # z
[(0,0), (1,0), (1,1), (2,1)], [(0,1), (1,0), (1,1), (0,2)], # Z
[(0,0), (0,1), (0,2), (1,1)], [(0,0), (1,0), (2,0), (1,1)], # ใ
[(0,1), (0,1), (1,1), (2,1)], [(0,0), (1,0), (1,1), (2,0)], # ใ
]
def can_put(x, y, shape):
for ax, ay in shape:
nx = x + ax
ny = y + ay
if nx < 0 or nx >= N or ny < 0 or ny >= M:
return False
return True
def put_tetris(x, y):
tmp_sum = 0
for shape in tetris:
if can_put(x, y, shape):
c_sum = 0
for ax, ay in shape:
nx = x + ax
ny = y + ay
c_sum += arr[nx][ny]
tmp_sum = max(tmp_sum, c_sum)
return tmp_sum
def solution():
max_sum = 0
for i in range(N):
for j in range(M):
max_sum = max(max_sum, put_tetris(i, j))
print(max_sum)
solution()
์ํ์ฃผ ์ต๊ณ ์ต๊ณ ~ |
๐ ๋ฌธ์ ๋งํฌ
ํ ํธ๋ก๋ฏธ๋ ธ
โ๏ธ ์์๋ ์๊ฐ
40 ๋ถ
โจ ์๋ ์ฝ๋
๋ฐฉ์ง์ฉ ํ์คํ๊ณ
์ ๋ ๊ทธ๋ฅ ๋ชจ๋ ๊ฒฝ์ฐ์ ์ ๋ค ๋๋ ค๋ฃ์์ต๋๋ค.
๋ค์ง๊ธฐ -> x ์ขํ์ * -1
90๋ ํ์ -> (x,y) -> (y, -x)
๊ตฌ๊ต์๋์ด ๋ฐฑํธ๋ํน์ผ๋ก ํ์๋ฐ์.
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ