[20260124] BOJ / P4 / 탈옥 / 김민진 #1827
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.
🧷 문제 링크
탈옥
🧭 풀이 시간
110분
👀 체감 난이도
✏️ 문제 설명
감옥에 있는 두 죄수를 모두 탈옥시키기 위해 열어야하는 문의 최소 갯수는?
🔍 풀이 방법
0-1 BFS 그런데
dist배열을 3차원으로 두는..감옥은 가장자리 문이 어디 달렸을지 모르니까 패딩을 넣어줌
→ 죄수 1, 죄수 2,
(0, 0)각각 세 지점에서 출발했을 때 열 수 있는 최소한의 문의 갯수를dist에 저장답은
dist순회하면서 나온 최솟값처음에는 죄수 2명만 가지고 계산했었는데 죄수 2명은 모두 감옥 내에 있기 때문에 둘만 가지고 계산하면 감옥 안에서 만난다고 할 때 열어야하는 문의 최솟값을 구하는 것이 됨
그렇기 때문에 감옥 밖의 제3자가 필요한 것..
답을 구할 때는 빈 칸일 때는 각자가 열고 온 문의 총합을 구하고 문일 때는 문에서 세 명이 모인 것이기 때문에 중복 제거(
-2)⏳ 회고
dist를 3차원으로 둬야겠다는 접근은 나름 해봤는데 감옥 외부의 존재를 넣을 생각은 안남.. 진짜 어려웟다..GPT가 요즘 똑똑하대서 문제 이해하는데 다시 써봤는데 나를 이해시키지 못함...... 말도 너무 많아.......