[20260319] BOJ / G5 / 공주님을 구해라! / 이준희#2032
Merged
ShinHeeEul merged 2 commits intomainfrom Mar 19, 2026
Merged
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.
🧷 문제 링크
https://www.acmicpc.net/problem/17836
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
벽 등으로 막혀있는 N*M 지도에서 공주님을 구하려고 합니다.
공주는 T초 이내에 구하지 못하는 경우 실패이며 Fail을 출력합니다.
T초 이내에 구하는 경우 구하는 데 걸리는 최소 시간을 출력합니다.
단, 용사에게는 그람이라는 검이 있고 맵 어딘가에 있는데, 이 검을 습득하면 모든 벽을 부수면서 나아갈 수 있습니다.
🔍 풀이 방법
BFS를 이용해서 풀었습니다.
기본적으로 공주한테 가는 BFS를 하고, 검에 도착하는 경우 모든 벽을 부술 수 있기 때문에
해당 시점에서 공주까지 직선거리(맨해튼거리)를 더하여 시간을 계산합니다.
최종적으로 일반 시간과 검을 가지고 간 시간을 비교하여 더 작은값을 출력합니다.
⏳ 회고
검을 들고 벽을 부수는 횟수 제한이 없어서 크게 어렵지 않았습니다.