[PGS] 지게차와 크레인 - #83
Open
been12151 wants to merge 20 commits into
Open
Conversation
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.
🍪 문제 이름
Resolve: 지게차와 크레인
🍊 문제 정의
inputstorage: 창고의 컨테이너 배치 상태를 나타내는 문자열 배열 (n × m 크기, 알파벳 대문자)requests: 출고 요청 배열 (길이 1이면 지게차, 길이 2이면 크레인)output예시
🍑 알고리즘 설계
창고 주변을
.으로 패딩해 외부 영역을 명시적으로 만든 뒤, BFS로 외부와 연결된 빈 칸(outside)을 탐색.outside에 인접한 해당 문자 칸을 모아 한 번에 제거요청마다 BFS로
outside를 갱신해 이전 제거로 새로 외부와 연결된 칸도 반영.🥝 최악 수행 시간 복잡도
O(r × n × m)(r = requests 길이, n × m = 창고 크기)🍰 특이 사항 (Optional)
지게차 처리 시 제거 대상을 바로 지우지 않고
to_remove에 모아 한 번에 처리한 부분이 중요. 즉시 제거하면 인접 칸이 새로 외부와 연결되어 같은 요청 내에서 연쇄 제거가 발생할 수 있음.