[20250804] BOJ / G5 / 선수과목 / 김수연 #606
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/14567
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
학부에 개설된 모든 전공과목을 들으려고 함.
어떤 과목들은 선수과목이 있어서 선수과목 조건을 반드시 지켜야할 때, 모든 과목에 대해 각 과목을 최소 몇 학기에 이수할 수 있는지 출력
🔍 풀이 방법
bfs 이용한 위상 정렬 사용
선수과목이 몇개 있는지 degree라는 배열에 저장하고,
degree에 저장된 값이 0인 과목부터 이수함.
이후, 하나씩 줄여나가면서 degree가 0이 된 과목을 이수할 수 있는 학기 저장해둠
⏳ 회고
오랜만에 푸니까 헷갈린다..