[20251210] BOJ / G4 / 친구비 / 이준희 #1631
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/16562
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
친구비를 통해서 친구를 사귀는 준석이가
친구의 친구는 친구다 라는 논리로 친구를 가성비 있게 만들려고 할 때
주어지는 모든 사람을 친구로 만들 때 필요한 최소비용을 구하는 문제입니다.
만약 모두 친구가 될 수 없다면 oh no 라고 출력합니다.
🔍 풀이 방법
bfs를 이용해서 방문하지 않은 노드를 방문하면서
한 묶음에 대한 최소 비용을 도출해서 각각 더했습니다.
⏳ 회고
간단한 그래프 탐색 문제였습니다.