[20251128] BOJ / P4 / Island Travels / 권혁준 #1530
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/5852
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
R*C 크기의 2차원 격자가 있고, 칸의 종류는 3가지이다.
'X'인 칸은 땅이고, 'S'인 칸은 얕은 물, '.'인 칸은 깊은 물이다.
땅으로 이루어진 최대 연결 요소 각각을 섬이라 부른다.
섬에서 섬으로 이동할 때는 땅이나 얕은 물을 거쳐서만 갈 수 있다.
어떤 섬에서 출발하여 모든 섬을 방문하려고 한다.
이때 지나가야 하는 얕은 물의 최소 개수를 구해보자. (같은 칸을 여러 번 방문하면 여러 번 센다.)
🔍 풀이 방법
BFS로 각 섬에 번호를 달아줬다.또 다른
BFS로 모든 섬들 사이에 얕은 물로만 이동 가능한 최단 거리를 구해줬다.이후
플로이드-워셜로 모든 섬들 사이의 진짜 최단 거리를 구해줬다.마지막으로
bit dp를 돌려서 최소 비용을 구했다.⏳ 회고
ez