[20250829] BOJ / G1 / 수영장 만들기 / 이종환 #770
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/1113
🧭 풀이 시간
70분
👀 체감 난이도
✏️ 문제 설명
지민이는 수영장을 만들려고 한다. 수영장을 만들 곳의 크기는 N*M이고, 각 칸은 직육면체이다
물은 항상 높이가 더 낮은 곳으로만 흐르고, 직육면체 위의 표면에는 물이 없다. 그리고, 땅의 높이는 0이고, 땅은 물을 무한대로 흡수 할 수 있다.
땅의 모양이 주어질 때, 수영장에 물이 얼마만큼 있을 수 있는지 구하는 프로그램을 작성하시오.
첫째 줄에 N과 M이 주어진다. N과 M은 50보다 작거나 같은 자연수이다. 둘째 줄부터 N개의 줄에 땅의 높이가 주어진다. 높이는 1보다 크거나 같고, 9보다 작거나 같은 자연수이다.
🔍 풀이 방법
처음에는 이걸 어떻게 풀어야하는 지 많이 막막했다. 그런데 다시 생각해보니 땅의 높이가 1
9라는 것에 주목하였다. 즉 물의 높이도 19만 가능한 것이다.이를 이용하여 물의 높이를 임의로 가정한 후, 그것이 가능한 지 BFS를 통해 확인하는 로직을 높이별로 반복하였다.
⏳ 회고
한 번에 보고 로직이 안 떠오르는 문제들은 의외로 쉬운 방법으로 풀리는 게 많은 것 같다.