[20250820] BOJ / G3 / 파티 / 이종환 #700
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
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
N개의 숫자로 구분된 각각의 마을에 한 명의 학생이 살고 있다.
어느 날 이 N명의 학생이 X (1 ≤ X ≤ N)번 마을에 모여서 파티를 벌이기로 했다. 이 마을 사이에는 총 M개의 단방향 도로들이 있고 i번째 길을 지나는데 Ti(1 ≤ Ti ≤ 100)의 시간을 소비한다.
각각의 학생들은 파티에 참석하기 위해 걸어가서 다시 그들의 마을로 돌아와야 한다. 하지만 이 학생들은 워낙 게을러서 최단 시간에 오고 가기를 원한다.
이 도로들은 단방향이기 때문에 아마 그들이 오고 가는 길이 다를지도 모른다. N명의 학생들 중 오고 가는데 가장 많은 시간을 소비하는 학생은 누구일지 구하여라
🔍 풀이 방법
결론부터 말하면 문제의 의도와 다르게 풀었는데 맞혔다...
난 모든 지역을 시작점으로 두고 다익스트라를 써도 N*M = 10,000,000 이니까 어떻게든 안터지겠지하고 풀어서 맞추긴 했는데,
생각해보니 모든 지역에서 파티 지점까지의 최단거리를 구할 때 일일히 다익스트라를 쓰는게 아니라, from과 to를 반대로한 edge들을 따로 만든 후, 이들에 대한 다익스트라를 쓰면 알아서 한번에 나오는 것이었다.
즉 기존 edge들을 통해 파티지점 to 다른 지점을 구하고, reverse Edge들을 통해 다른 지점 to 파티 지점을 구해서 이들의 합이 최대인 지점을 구하면 된다.
⏳ 회고
내 풀이시간만 길어서 확인해보니 이런 차이가..