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/5551
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
정점 N개, 간선 M개인 그래프가 있고, 정점들 중 K개의 정점은 쇼핑몰이다.
쇼핑몰로부터 가장 거리가 먼 집까지의 거리를 구해보자.
단, 집은 정점에 있거나 간선 위에 있을 수도 있다.
🔍 풀이 방법
집이 정점 위에 있는 경우는 다익스트라로 쉽게 구할 수 있다.
K개의 쇼핑몰을 모두 시작점으로 두고 PQ에 넣은 뒤 돌리면 된다.
어떤 간선 (u,v,cost)에 대해, 이 위에 집이 있다면, 가장 시간이 오래 걸리는 경우는 dist[u], dist[v], (dist[u]+dist[v]+cost)/2 중 최댓값이 된다.
따라서 각 간선에 대해 저 값을 모두 확인해주면 된다.
⏳ 회고
같은 아이디어를 사용하는 문제가 바로 떠올랐다.
https://www.acmicpc.net/problem/13141