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/23258
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
정점 N개 짜리 그래프가 주어지고, 간선에 가중치가 존재한다.
x번 집에는 2^x의 이슬이 있고, 출발지와 도착지를 제외하고 거치는 집들에 있는 이슬을 모두 마시게 된다.
Q번의 질문에 답해보자.
🔍 풀이 방법
쿼리를 일단 다 받아놓고 c를 기준으로 정렬해서 플로이드 워셜을 천천히 돌렸다.
새로운 2차원 배열 val을 둬서,
val[s][e] = 현재 상황에서 s와 e가 모두 limit이상일 때의 최단 경로로 정의했다.쿼리를 처리하면서 limit이 늘어날 때마다 val[s][e]를 모두 업데이트 해줬다.
val[s][e] = min(cost[s][limit] + dist[limit][k] + cost[k][e], cost[s][k] + dist[k][limit] + cost[limit][e])
쿼리의 c, s, e값을 비교해서 dist 혹은 val에서 답을 구해줬다. 근데 왜 틀리지
⏳ 회고
요즘 문제 제출만 하면 계속 틀렸다고 그러니까 풀고 싶은 의지가 꺾인다.
아무리 생각해도 맞는데 좀 더 고민해봐야겠다