[20251019] BOJ / G1 / 굉장한 모비스터디 / 한종욱#1160
Merged
ShinHeeEul merged 1 commit intomainfrom Oct 19, 2025
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/27726
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
세 개의 수업이 끝나고 스터디를 맺는데, 세 개의 수업의 스터디를 모두 같은 스터디를 하는 스터디를 굉장한 모비스터디라고 한다.
존재하는 굉장한 모비스터디의 개수와 거기 멤버들을 오름차순으로 출력하시오.
🔍 풀이 방법
서로 분리집합을 통해 관계를 맺은 후
처음엔 map에 각 노드를 하나씩 대조하면서 넣었다. map에는 노드들이 중복으로 저장되어 최악의 경우 공간복잡도가
BFS에서 visited를 Set으로 선언하듯, 세 스터디의 root를
String key = find(node, 0) + "," + find(node, 1) + "," + find(node, 2);로 선언했다. 이렇게 하면 각 노드를 1번씩만 탐색해 공간복잡도가그 다음 각 그룹의 크기가 2이상인 것만 정렬해 저장하고, 각 그룹의 최소값을 기준으로 오름차순 정렬을 했다.
⏳ 회고
visited를 Set으로 선언하는 걸 map에서도 할 수 있다는 생각을 하지 못했다.