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/28296
🧭 풀이 시간
25분
👀 체감 난이도
✏️ 문제 설명
정점 N개, 간선 M개인 그래프의 각 정점은 1번 회사부터 K번 회사중 하나에 속해있다.
간선에는 정수 가중치가 붙어있다.
두 정점의 배송 상한선은 두 정점을 연결하는 경로상의 간선들 중 가장 작은 가중치를 말한다. 만약 경로가 여럿 존재한다면, 배송 상한선이 가장 큰 경로를 선택한다.
1번 ~ K번의 각 회사에 대해, 해당 회사에 속한 정점들끼리의 배송 상한선의 총합을 구해보자.
🔍 풀이 방법
[사용한 알고리즘]
이런 문제는 간선 가중치가 큰 순서대로 크루스칼을 돌리며 내려오는 게 정석이다.
컴포넌트를 합칠 때마다, 각 컴포넌트에 존재했던 회사 정보들을
작은 집합에서 큰 집합으로 합치는 테크닉으로 합쳐준다.두 컴포넌트에 있던 회사의 개수를 곱해준 것이 해당 간선을 배송 상한선으로 가지는 경로의 수를 의미한다.
⏳ 회고
이런 문제 너무 재밌음