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/1865
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
도로와 웜홀이 주어지는데, 웜홀을 통과하면 주어진 시간만큼 시간이 거꾸로 간다.
출발을 하여 다시 출발을 했던 위치로 돌아왔을 때, 출발을 했을 때보다 시간이 되돌아가 있는 경우 구하기
🔍 풀이 방법
음수의 가중치도 존재하기 때문에 벨만-포드 알고리즘을 사용했다.
N-1번 반복하며 각 노드에 도달하기 위한 최소의 시간을 저장해두고, N번째에서 지금까지 저장된 값보다 작은 값이 나온다면 음의 사이클이 존재하는 것이므로, true를 반환했다.
⏳ 회고
벨만-포드 알고리즘을 오랜만에 사용해서 헤맸다..