[20260320] BOJ / G3 / 다리 만들기 / 이준희#2034
Merged
ShinHeeEul merged 1 commit intomainfrom Mar 20, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/2146
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
격자 모양의 세계에 섬과 바다가 각각 1과 0으로 표시되어 있습니다.
이 때 서로다른 두 섬을 최소 길이의 다리로 이었을 때 그 길이를 출력하는 문제입니다.
🔍 풀이 방법
입력받은 맵에서 서로 다른 섬을 구분해야하기 때문에 각 섬에 번호를 붙혔습니다.
맵을 순회하면서 1을 발견하면 해당 위치부터 bfs를 수행해 모든 1을 방문하면서 번호를 바꾸어 주었습니다.
이후 각 섬마다 섬의 모든 좌표들을 bfs 큐에 집어넣은 후 bfs를 수행하여 번호가 다른 육지에 도착하는 경우를 다리가 생성되는 경우로 간주하여 거리를 측정했습니다.
각 섬마다 모두 체크하되 minDist를 두어 건너 뛰면서 체크하여 시간을 줄였습니다.
⏳ 회고
처음에 섬 넘버링 하는 것을 빠르게 떠올리지 못해서 오래걸렸던 것 같습니다.