[20251214] BOJ / P4 / 유럽여행 / 한종욱 #1669
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/1185
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
유럽여행을 갈 껀데, 길은 N-1개만 사용할 꺼고 시작나라에 다시 돌아와야 한다. 그때 최소 비용은?
🔍 풀이 방법
N-1개의 길만 사용한다는 의미는 사이클이 되지 않는다는 것이다. 그럼 트리 형태이고 트리 형태라면 무조건 왕복비용이 든다는 말이다.
따라서, 가중치를
해당 길의 가중치x2 + a나라의 비용 + b나라의 비용으로 계산해야 한다.그리고 우린 시작나라를 정해야 한다. 그건 각 나라의 비용 중 가장 낮은 비용의 나라를 선택하면 된다.
⏳ 회고
이게 MST라는 걸 이해하는데 제일 어려웠던 문제이다. 사이클이 아니라면 트리 형태로 왕복해야만 한다는 걸 몰랐다.