[20250705] BOJ / G3 / 피리 부는 사나이 / 이강현 #416
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/16724
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
성우가 피리를 불면 N X M 필드에 정의된 명령에 따라 회원들이 움직여야 함.
근데 재훈이가 지친 회원들을 위해서 명령에 따르지 않아도 되는 save zone을 만들려고 함.
이때, 필드의 어디 부분에 있든 save zone으로 갈 수 있게 하려고 하는데 그때 save zone의 최소 개수를 출력.
🔍 풀이 방법
분리 집합, DFS
분리 집합으로 풀었는데 2차원이므로 i,j를 가지는 pos라는 객체를 만들어서 equals와 hashcode를 재정의했음.
이후 모든 필드에서 명령에 따라 만나게 되는 인접 필드와 merge를 하는 방식을 진행하고
hashset을 이용해서 pos의 개수를 셈
⏳ 회고
흠냐