[20251029] BOJ / G1 / 최종 순위 / 이준희 #1258
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/3665
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
어떤 시합에서 작년에는 순위를 공지했으나 올해는 안한다고 합니다.
그러나 작년과 비교해서 상대순위가 바뀐 경우에 그 쌍을 공지한다고 합니다.
이 때 올해의 순위를 알 수 있는 경우 순위를, 확실하지 않은 경우 ? 를 찾는게 불가능한 경우 IMPOSSIBLE을 출력하는 문제입니다.
🔍 풀이 방법
일단 작년 순위를 기준으로 방향이 있는 간선을 만들어놓고
다음 해의 상대 순위 쌍을 받아서 그 방향을 반대로 만들어서 저장합니다.
이를 이용해서 위상정렬하여 찾았습니다.
⏳ 회고
위상정렬 문제를 오랜만에 봐서 좀 어려웠던 것 같습니다.