[20250714] BOJ / G4 / 저울 / 이종환 #465
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/10159
🧭 풀이 시간
40 분
👀 체감 난이도
✏️ 문제 설명
물건의 개수 N 과 일부 물건 쌍의 비교 결과가 주어졌을 때, 각 물건에 대해서 그 물건과의 비교 결과를 알 수 없는 물건의 개수를 출력하는 프로그램을 작성하자.
🔍 풀이 방법
Stuff라는 커스텀 클래스를 만든 후, 각각 직접적으로 비교된 더 무거운 물건들(parents)와 더 가벼운 물건들(children)을 필드값으로 가지게 하였다.
이후 pq에 넣고 parent가 적은 순으로 꺼내서, 물건의 숫자를 parents와 children에게 재귀를 통한 완탐시킴으로써 전파하였다.
⏳ 회고
분명히 비슷한 문제들을 꽤 푼 것 같은데 오랜만이 푸니까 잘 풀리지도 않고 코드도 더럽다.... 좀 더 연습해쟈ㅣ