Skip to content

Conversation

@beberiche
Copy link
Contributor

No description provided.

@github-actions
Copy link

github-actions bot commented Apr 5, 2024

솔루션을 올려주셔서 감사합니다.
아래 정보가 맞는지 확인해주세요.

문제 링크: https://www.acmicpc.net/problem/1507

작성자: beberiche
언어: Java
사이트: baekjoon
풀이 설명: 
1. 플로이드-워셜 응용 문제. 최단 경로의 결과가 입력 값으로 주어지고, 이를 기반으로 본래 사용된 간선을 확인한다.

2. 플로이드-워셜의 핵심은 현재 간선 비용보다 우회하여 오는 간선의 비용이 더 적은 경우 업데이트를 하는 것이다. 
   따라서 우회한 간선의 합이 현재의 간선 비용과 동일하다면, 우회한 간선 쪽을 반영한 것이라고 추론할 수 있다.

3. 우회한 간선이 반영된 경우를 \`0\` 으로 변경하자. 
   모든 탐색이 끝난 이후에도 \`0\` 이 아닌 간선이 본래 최단 경로를 결과를 찾기 위해 사용된 초기 간선이 된다. 

4. 탐색 시, 현재 간선보다 우회한 간선의 합이 더 큰 경우, 
   최단 경로를 잘못 파악한 것으로 간주하고 \`-1\` 을 출력한다.


@github-actions github-actions bot added solution 솔루션 PR Java Java baekjoon baekjoon labels Apr 5, 2024
Copy link
Owner

@tony9402 tony9402 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tony9402 tony9402 merged commit 91f1352 into tony9402:main Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants