[20250714] BOJ / P3 / 로버트 후드 / 권혁준 #462
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/9240
🧭 풀이 시간
15분
👀 체감 난이도
✏️ 문제 설명
좌표평면에 점 N개가 주어지면, 가장 멀리 떨어진 두 점 사이의 거리를 구해보자.
🔍 풀이 방법
N개의 점들로 볼록 껍질을 만든다. 볼록 껍질에 포함되지 않는 점은 절대로 정답 후보에 포함될 수 없다. (반드시 볼록 껍질에 포함된 점들로 더 먼 거리를 만들 수 있다.)
볼록 껍질 상에서 투 포인터를 수행한다.
투 포인터 i, j에 대해, 점 P[i], P[i+1], P[j], P[j+1]을 준비하고,
두 벡터 P[i] -> P[i+1], P[j] -> P[j+1]가 이루는 방향이 반시계라면 j를 늘린다.
그렇지 않다면 i를 늘린다.
이 방식으로 옮겨가며 만나는 (i, j)에 대해, 점 P[i]와 P[j]의 거리 중 최댓값이 정답이 된다.
⏳ 회고
https://www.acmicpc.net/problem/2049
가장 먼 두 점을 구하는 기본 문제이다.