[20251208] BOJ / G3 / 욕심쟁이 판다 / 이강현 #1614
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/1937
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
판다는 상하좌우로 이동하며 대나무를 먹음.
대나무는 현재 먹은거보다 더 많은 양을 먹어야함.
이동하면서 가장 많은 칸으로 이동하며 먹을때 해당 칸을 출력.
🔍 풀이 방법
DFS, dp
DFS에 visited를 dp로 구현
⏳ 회고
dp는 현재 지점에 앞으로 얼마만큼 먹을 수 있는가를 저장해두어야 함.
그리고 모든 지점에서 DFS를 하는데, dp값이 있으면 그걸 사용하도록 구현함.
이때 한가지 생각이 들었음.
dp 값이 5라고 한다면 현재 지점에서 4칸을 더 가면서 대나무를 먹는다는 건데, 그 지점을 거쳐서 온 경우라면?
하지만 이런 경우는 존재하지 않음.
무조건 대나무를 증가하면서 먹기때문에, 현재지점에 도달했을때는 이 지점보다 무조건 적은 대나무를 먹으면서 온 경우이고 이후 앞으로 먹을 4칸들은 현재 지점보다 무조건 큰 지점들이기에 절대로 겹칠 수 없다는 것이 문제의 핵심이었음.