[20251214] BOJ / G5 / 토마토 / 강신지 #1671
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/7569
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
여러 층으로 이루어진 토마토 상자에서 익은 토마토는 하루가 지나면 상하좌우앞뒤로 인접한 익지 않은 토마토를 익게 만든다.
모든 토마토가 익기까지 걸리는 최소 일수를 구하고, 끝까지 익지 못하는 토마토가 있으면 −1을 출력하라.
🔍 풀이 방법
기존 2차원 bfs에서 z방향을 더해 3차원 bfs
익은 토마토들을 모두 큐에 넣고 bfs 돌리면서 익지 않은 토마토의 개수를 관리
모두 익으면 경과 일수를 출력, bfs 종료 후에도 남아 있으면 −1을 출력
⏳ 회고
처음부터 다 익어있을 경우를 처리해주어야함!!