[20250623] BOJ / G1 / 열쇠 / 이강현 #381
Merged
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.
🧷 문제 링크
https://solved.ac/profile/dlrkdgus999
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
건물 평면도가 주어질때, 외부에서 들어와 문서를 최대한 많이 챙겨갈 때 얻는 개수를 출력.
알파벳 대문자는 문이며, 상응하는 알파벳 소문자가 있어야 문을 열 수 있음. 별은 벽임.
🔍 풀이 방법
BFS
열쇠를 얻어야 벽을 열 수 있고 벽을 먼저 만날지, 열쇠를 먼저 만날지 알 수 없음. 따라서 열쇠를 저장해두고 건물 외곽 입구를 큐에 모두 넣어둔채로 BFS를 실행.
열쇠가 추가된다면 전체 탐색을 다시 진행하고 아니라면 현재 문서 수를 출력.
⏳ 회고
BFS 구현 문제는 변형이 너무 어려움..