[20250206] BOJ / 골드2 / The Other Way / 권혁준 #55
Merged
+112
−0
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/14554
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
정점$N$ 개, 간선 $M$ 개인 무방향 그래프에서 $S$ -> $E$ 최단 경로의 개수 구하기
🔍 풀이 방법
다익스트라 돌면서 새로운 배열 C에 경로의 개수를 저장해 주었다.
C[i] = i까지 오는 최단 경로의 수
D[i]가 갱신될 때 C[i]까지 같이 갱신해주면 된다.
D[i]가 갱신되지 않고, 같은 값이 들어오면 경로 수를 C[i]에 더해줘야 한다.
⏳ 회고
Comparator의 비교 함수 리턴값은 항상 int여야 한다는 걸 처음 알았다..