[20250922] BOJ / G5 / 회장뽑기 / 이준희 #948
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/2660
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
각 사람의 점수 산출 방식은 아래와 같습니다.
다른 모두와 친구인 경우 1점
다른 모두와 친구이거나 친구의 친구인 경우 2점
다른 모두와 친구이거나 친구의 친구의 친구인 경우 3점 ...
회장 후보는 점수가 가장 낮은 사람이 될 수 있을 때
회장 후보의 점수, 후보의 수, 후보를 오름차순 으로 출력하는 문제입니다.
🔍 풀이 방법
플로이드-워셜을 이용하여 풀었습니다. 직접 친구인 경우를 1로 만든 후 3중for문을 순회하며 다른 사람에게 도달하기 까지의 거리를 구했습니다. 이 때 이 거리가 그 사람의 점수가 됩니다.
이후 다시 모든 n 을 순회하며 점수를 구한 후 가장 낮은 점수를 계산하여 풀었습니다.
⏳ 회고
BFS로 풀려다가 생각해보니 플로이드가 더 빠를 것 같아서 다시 풀었습니다