[20250911] BOJ / G3 / 별자리 만들기 / 이준희 #866
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/4386
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
별의 갯수와 각 별의 실수 좌표가 주어질 때
모든 별을 이어서 별자리를 만드는 경우 중 비용이 최소가 되는 경우를 구하는 문제입니다.
별과 별 사이의 거리가 비용입니다.
🔍 풀이 방법
유니온-파인드 이용해서 최소 스패닝 트리 구현했습니다.
edge 자체가 주어지지 않기 때문에 우선 별들의 리스트를 만들고
해당 리스트를 순회하며 edge 리스트를 만들어서 풀었습니다.
⏳ 회고
오랜만에 보는 최소 스패닝 트리 문제라서 기억을 떠올리는데 조금 오래 걸렸습니다.
edge 리스트에서 처음에 node 자체를 관리하려고 생각했는데 잘 되지 않아서 index 관리하는 방식으로 변경했습니다.