[20251028] BOJ / G1 / 배달 / 한종욱 #1251
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/1175
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
C를 모두 탐색해야 하는데, 이전에 들어왔다는 방향으론 두 번 못간다. 최단 시간은?
🔍 풀이 방법
visited[][][][]로 놓고 각 좌표는 도달한 C에 따라 구분하고 도달한 방향에 따라 구분한다.
상태를 저렇게 놓고 BFS를 처리하면 된다.
⏳ 회고
같은 값을 두 번, 세 번 방문할 수도 있다. 방향에 따라 다르기 때문에, 그때마다 더하기보단
|연산을 통해 일관성 있게 처리해야 한다.