Repository navigation
[W11] 김대원 주간 풀이 - #68
Open
dae-won-kim wants to merge 1 commit into
Open
dae-won-kim wants to merge 1 commit into
dae-won-kim wants to merge 1 commit into
Conversation
Contributor
🤖 PR 자동 분석
변경된 풀이
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 핵심 접근
매 턴을
moveBox→loadOrCrash→putBox3단계로 나눠 시뮬레이션했습니다.1단계 (이동,
moveBox)checkMoveBox: 앞 칸이 비었거나 앞 칸 박스가 이번 턴에 움직이면competeForNext로 경합하고, 앞 칸 박스가 못 움직이면 현재 박스도 못 움직입니다.competeForNext: 칸마다comingBoxId에 지금까지의 승자를 저장하고,isHigher(무게 내림차순 → 번호 오름차순)로 비교해 승자를 바꿉니다. 진 박스는setMovable(false)처리합니다.makeMove: 판정이 끝나면 칸마다 자기 칸의 플래그만 보고 다음 상태를 정합니다. 들어오는 박스가 있으면 그 박스가 새 주인이 되고, 없는데 내 박스가 움직였으면 빈 칸이 됩니다. 그래서 격자 하나를 바로 수정해도 문제가 없습니다.2단계 (적재 / 파손,
loadOrCrash)stopCnt를 0으로, 못 움직였으면 1 올리고, 3 이상이 되면 파손 표시를 합니다.3단계 (투입,
putBox)투입 시각이 지난 박스 중에서 칸별로 투입 예정 턴이 가장 이른 박스 하나를 고르고, 그 칸이 비어 있을 때만 올립니다.
칸 쪽
canCurrentBoxMove와 박스 쪽curTurnMove가 따로 어긋나지 않도록, 두 값은setMovable에서만 바꾸게 했습니다.🔍 리뷰 요청
moveBox: 적재 칸마다visited를 새로 만들어 BFS를 돌고 있습니다. 서로 다른 적재 칸의 BFS가 같은 칸을 지나서 판정이 겹치는 경우는 없는지, 그리고 적재 칸으로 이어지지 않는 벨트(사이클 등) 위의 박스가 판정에서 빠져도 괜찮은지 봐주시면 감사하겠습니다.competeForNext: 경합에서 진 이전 승자를 나중에setMovable(false)로 되돌리는 방식입니다. 같은 칸을 노리는 박스들은 같은 BFS 단계에서 판정되고 그 뒤 칸들은 다음 단계에서 판정되므로 괜찮다고 판단했는데, 이 가정에 빈틈이 없는지 봐주시면 감사하겠습니다.putBox와loadOrCrash가 매 턴 전체 박스를 다 도는데, 박스 수가 많을 때 칸별 대기 큐 같은 방식으로 바꾸는 게 나을지 궁금합니다.🤖 Generated with Claude Code