[20250821] BOJ / G1 / 청소년 상어 / 이준희 #706
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/19236
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
4*4 배열에 방향과 번호를 가진 물고기가 있고
여기에 청소년 상어가 들어가서 돌아다니면서 물고기를 먹습니다.
상어는 먹은 물고기의 방향을 갖게 되고 해당 방향에 먹을 수 있는 물고기가 없으면 종료됩니다.
상어가 먹을 수 있는 물고기 번호의 합 중 최대값을 구하는 문제입니다.
🔍 풀이 방법
백트래킹을 이용하여 풀이했습니다
이 때 상어는 바라보는 방향의 여러 칸 중 1개의 칸으로 선택하여 이동할 수 있기 때문에
각 분기점을 관리하기 위해 매 depth 마다 해당 상태 배열을 복사하면서 진행했습니다.
⏳ 회고
오랜만에 상어 시리즈를 풀이해봤는데 역시 쉽지 않았던 것 같습니다.
문제를 보자마자 어떤식으로 풀어야 할지는 바로 알았는데 시뮬레이션 구현이 시간이 걸렸습니다.