[20250927] BOJ / P5 / 안대 낀 스피드러너 / 한종욱 #989
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/14451
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
BFS인데 두 가지 상태를 동시에 할 생각을 할 수 있어?
🔍 풀이 방법
visited를 [위를 첫 방향으로 시작한 x위치][위를 첫 방향으로 시작한 y위치][위를 첫 방향으로 방향] [오른쪽을 첫 방향으로 시작한 x위치][오른쪽을 첫 방향으로 시작한 y위치][오른쪽을 첫 방향으로 방향]로 정의한다.
이렇게 정의하면 우리가 아는 BFS와 동일하다.
⏳ 회고
생각도 안나서 힌트를 봤다. 근데 고정관념에 갇혀있어서 그랬던 거 같다. 같은 길을 간다는 건 두 상태를 같이 정의하면 된다는 의미였는데 이해하지 못했다. visited의 상태정의를 보자마자 바로 이해했다. 참고로 두 방향 중 한 방향이 도착하면 그 방향은 처리하면 안된다.