[20250926] BOJ / G4 / 미로만들기 / 이준희 #979
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://www.acmicpc.net/problem/2665
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
n*n 모양의 맵에 n^2개의 방이 있는데 이 중 흰방은 지나갈 수 있고 검은방은 지나갈 수 없습니다.
0,0 에서 n-1,n-1 까지의 미로를 만들려고 할 때 흰방으로 바꿔야하는 검은방의 최소 갯수를 구하는 문제입니다.
🔍 풀이 방법
0-1 BFS를 활용하여 풀었습니다.
흰방은 코스트가 0, 검은방은 코스트가 1로 계산하여 코스트가 1인 경우에는 큐의 마지막에 집어넣어서 연산을 후순위로 미뤘습니다.
그리고 dist 배열을 갱신해 가며 풀었습니다.
⏳ 회고
예전에 0-1BFS 문제를 한 번 풀었던 적이 있는데 그 기억으로 풀었습니다.