[20250227] BOJ / 골드3 / 파티 / 김수연 #192
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/1238
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
N명의 학생이 X번 마을에 모여서 파티를 개최
각 학생들이 단방향 도로들을 통해 최단 시간에 오고 간다.
i->X->i로 오는 시간이 가장 오래 소요되는 학생의 시간 구하기
🔍 풀이 방법
다익스트라를 사용해서 각 학생들 별로 dijkstra(i, X) + dijkstra(X, i)를 구해서 MAX값을 찾았다.
다익스트라를 할 때, PriorityQueue에 넣는 것들의 가지치기를 하지 않으면 메모리 초과가 뜬다.
플로이드-워셜 알고리즘으로도 풀 수 있다는데 그러면 시간초과가 뜬다.
⏳ 회고
X를 향해 갈 때와 X에서 돌아올 때의 값들을 배열에 저장해두면, 걸리는 시간을 줄일 수 있다.
다익스트라 오랜만에 하니 얘도 헷갈린다....