[20250211] BOJ / 플래5 / 팀 편성 / 권혁준 #78
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/1154
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
학생이$N$ 명 주어지고, 서로 아는 관계가 모두 주어진다. (간선 형태로)
학생들을 두 팀으로 나눠보자.
각 팀에 속한 학생들끼리는 서로 모두 아는 관계여야 한다.
🔍 풀이 방법
1부터 시작해서, 서로 아는 관계가 아닌 점들로 계속 탐색을 이어갔다.(dfs)
탐색 중에 모순이 발생하면 해가 없고, 그렇지 않으면 두 팀을 출력해줬다.
⏳ 회고
문제에 두 팀으로 나누라고 되어있어서, N = 1인 경우에는 당연히 불가능인 줄 알았는데, 팀이 비어있어도 되는 거였다.
너무 화가 난다