[20250803] BOJ / P5 / 우주 정거장 / 권혁준 #601
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/20930
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
2차원 좌표평면에 N개의 우주 정거장이 있다.
우주 정거장은 선분 형태이다.
비행선은 우주 정거장에서 출발하며, 아래 이동 방식으로만 이동 가능하고 우주 정거장에서만 멈출 수 있다.
서로 다른 두 정거장 사이를 오갈 수 있는지 Q번 답해보자.
🔍 풀이 방법
선분이라서 복잡하게 느껴졌는데, 축 독립적으로 생각해도 상관 없다.
각 선분을 x축 따로, y축 따로 분리하면 총 두 개의 선분이 생긴다.
이걸 정렬해서 스위핑하며 우주 정거장간에 간선을 만들어줄 수 있다.
분리 집합으로 관리하면 나중에 서로 오갈 수 있는지 빨리 판별할 수 있다.
⏳ 회고
행성 터널 문제에서 사용된 아이디어랑 거의 같아서 할만했다