[20250217] BOJ / 골드4 / 테트로미노 / 설진영 #133
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/14500
🧭 풀이 시간
25분
👀 체감 난이도
✏️ 문제 설명
테트로미노 블록을 특정 배열에 뒀을때, 바로 아래 깔리는 숫자들의 합이 최대가 되도록 할 때, 그값은?
🔍 풀이 방법
어렵게 생각할 필요 없이, 최대 길이를 4로 제한하고 전 방향을 그래프 탐색하듯이 탐색하면 된다. 그런데 여기서 중요한 것은 두번째 블럭 이후에는 한쪽 방향이 아니라 좌우 하나씩 가는 경우도 있음을 고려해야 한다.
나는 최대 길이가 4이기 때문에(4일때는 왔던 방향으로만 가지 않으면 만날 일이 없으므로)방문 배열을 사용하지 않고 이전 방향을 인자로 받아 재귀를 돌리는 방법으로 구현했는데, 그것보다 정석적으로 방문 배열을 만들고 그리고 2에서도 재귀를 다시 돌리는 방향으로 구현하는 것이 더 깔끔한 것 같다.
⏳ 회고
분명 옛날에 봤던 문제인것 같기도 하고.. 그리고 이상하게 풀려고 하지 말고 정석 풀이를 좀 익혀야겠다..