[20251128] BOJ / P5 / 바리스타의 힘 / 이강현 #1532
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/24439
🧭 풀이 시간
3일
👀 체감 난이도
✏️ 문제 설명
이전 PR에 있음
🔍 풀이 방법
BFS
이전 PR과 다른 건, 하나의 반례가 있음.
기술을 사용할 때, 맨 왼쪽에서 한번만 하는 경우로 다 가능하다고 생각했는데 틀렸음.
예를 들어 아래와 같을때,
011111
000001
111101
100001
101011
111100
마지막에서 두번째 행에서 4번째 열에 해당하는 쪽에서 오른쪽으로 스킬을 사용해서 목적지로 가는 경우가 최단 거리지만
맨 왼쪽에서 한번에 하는 것을 구현하여 더 느리게 가버림. 따라서 맨 왼쪽 혹은 맨 위에서 기술을 사용해보되,
매 순간 갈 수 있는 부분이고 더 최단 거리라면 그걸 사용하는 코드를 추가해서 해결했다.
⏳ 회고
BFS를 항상 한번만 한다는 생각을 버리자.
시작점과 도착점이 주어진다면 더더욱