[20251113] BOJ / P2 / ATM / 권혁준 #1397
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/4013
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
정점 N개, 간선 M개인 방향 그래프가 주어진다.
각 정점 i에는 돈이 a[i]원 있는 ATM 기기가 있다.
P개의 정점은 레스토랑으로 지정되어 있다.
정점 S에서 출발하여 레스토랑 중 한 곳에 도착하는 동안 지나는 모든 ATM에서 돈을 한 번씩 뽑을 때, 돈을 최대 얼마나 가질 수 있는지 구해보자.
🔍 풀이 방법
점과 간선을 중복 방문할 수 있으니까, 어떤 점에 도착한다면 그 점이 속한
SCC의 모든 점들 또한 자유롭게 방문할 수 있다.그래프의
SCC들을 모두 구해서, 각SCC를 정점으로 갖는 새로운 그래프 G를 만든다.이렇게 만들어진 그래프는 무조건 방향 비순환 그래프라는 특징이 있다.
따라서 점 S가 속한 SCC에서 출발해서
위상 정렬+DP로 각 점까지의 최대 액수를 구해놓고, 이 중 레스토랑이 속해있는 SCC들에 대한 값만 고려하여 최댓값을 출력해줬다.⏳ 회고
어렵다