[20251023] BOJ / G3 / 나는 가르친다 스위핑을 / 한종욱 #1203
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/14266
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
선분들이 많이 주어지는데, 원점을 통과하는 직선을 그었을 때 가장 많은 선분을 통과하는 개수는?
🔍 풀이 방법
이벤트로 나눠서 선분이 시작하는 이벤트, 끝나는 이벤트를 나눠서 저장한다.
시작과 끝은 기울기를 기준으로 나눌 수 있다.
그런 다음 정렬을 할 땐, 같은 점이어도 시작점을 먼저 놓고 끝점을 뒤에 놔야 계산할 때 바르게 계산이 된다.
⏳ 회고
기울기로 정렬할 생각을 못해서 틀렸고, 지금은 double로 기울기를 계산했지만 정확히 하려면 비례식으로 long으로 계산해야 오차가 없을 것이라 생각한다.