[20250715] BOJ / G1 / 낚시왕 / 이강현 #472
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/17143
🧭 풀이 시간
120분
👀 체감 난이도
✏️ 문제 설명
낚시왕이 상어 낚시를 함. 낚시왕은 처음에 배열의 가장 왼쪽의 최상단보단 한칸 왼쪽에 있음.
상어는 R x C 배열 위에 있고 각 상어는 속력, 방향, 크기를 가짐.
낚시는 다음과 같은 과정에 따라 진행됨.
상어는 속력, 방향에 따라 배열 위를 이동하고 만약 같은 상어가 같은 위치에 존재하면 크기가 큰 상어가 작은 상어를 잡아 먹음.
낚시왕은 낚시를 할때 해당 열에서 가장 가까운 상어를 잡음.
🔍 풀이 방법
구현
상어들의 다음 위치를 구하는 함수
상어를 잡는 함수만 구하면 된다.
다음 위치들은 서로 충돌될 수 있으므로 상어들의 경합을 고려해서 조건에 맞게 잘 구현한다.
⏳ 회고
풀고 나니 그렇게 어렵지 않아 보인다. 상어들의 다음 상태를 저장할때, 같은 배열을 자꾸 사용하려다가 생각이 꼬여서 오래걸린 것 같다. 다음에 이러한 문제처럼 동시에 다수가 움직여야하고 충돌을 고려해야할때는 바로 새 배열을 사용해서 저장하는 생각을 떠올려야 할 것 같다. 구현 연습 필요함.