[20250317] BOJ / 골드2 / 통나무 옮기기 / 이강현 #248
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/1938
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
2차원 배열에서 3개의 인접한 통나무들을 원하는 지점까지 옮기기 위해 필요한 최소 작업 수를 출력.(상,하,좌,우,회전)
주변에 나무가 있는 경우 이동할 수 없고 회전반경에 나무가 있는 경우도 작업을 진행할 수 없다.
🔍 풀이 방법
BFS
⏳ 회고
솔직히 그렇게 어렵진 않았는데 핵심적인 문제부분은 회전은 제자리에서 하고 이동은 무조건 이동하기 때문에 이 둘을 다른 방법으로 방문 체크가 이루어져야 했음. 예를 들어 (2,1)에서 상하좌우를 체크해서 (1,1)을 큐에 넣었다고 가정하면 이것에 대한 방문을 체크했을 때 (1,1)에서의 회전이 이루어지지 않는 것이 문제였음. visited[i][j][0]으로 이동하는 경우와 visited[i][j][1]로 여기서 회전을 진행했는지로 나누어 체크해주는 것이 정답