Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/9466
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
모든 학생들이 프로젝트를 함께하고 싶은 학생을 선택할 때,
사이클이 만들어지는 경우에만 팀을 이룰 수 있다.
어느 프로젝트 팀에도 속하지 않는 학생들의 수 구하기
🔍 풀이 방법
dfs 사용
dfs 사용하되, 방문했는지 여부 표시하는 visited 배열 만들고,
만약 visited가 true인 곳을 방문하게 되면 사이클이 형성된 것이므로,
check 배열에서 사이클에 속한 학생을 true로 바꾸고, cylce 형성 학생 수 증가시킴
만약 check 배열에서도 true면 이미 고려되어 있는 학생이라 넘어감
⏳ 회고
처음에는 복잡하게 생각했는데, 단순하게 생각하면 됐다