[20251007] BOJ / G3 / 게리멘더링 / 이준희 #1062
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/17471
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
2개이상 10개 이하의 마을이 있는 나라에서 2개의 당이 선거구를 나눠먹으려고 합니다.
선거구를 나눠먹을 때는 각 당이 최소 1개의 선거구를 갖고 있어야 하고
각 당의 선거구끼리는 연결되어 있어야 합니다.
마을, 마을을 연결하는 길의 정보, 각 마을의 인원수가 주어졌을 때
두 당의 선거구의 인원의 차이가 가장 적은 경우의 인구차이를 구하는 문제입니다.
🔍 풀이 방법
조합을 이용해서 각 당의 선거구 리스트를 뽑고
BFS를 이용하여 각 선거구들이 연결되어 있는지 확인한 후
다 통과하는 경우에 인구수를 계산했습니다.
⏳ 회고
뭔가 여러가지를 짬뽕해서 풀었는데 크게 어렵지는 않았습니다.
N이 10 이하의 작은 수여서 브루트포스 식으로 모든 조합을 다 찾아도 통과 가능해서 그랬던 것 같기도 합니다.