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/25925
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
좌표평면에 N개의 점이 주어진다.
어떤 점에서 출발해서 지날 수 있는 점 개수의 최댓값을 묻는 질문에 Q번 답해보자.
🔍 풀이 방법
점들을 y좌표 기준 오름차순으로 정렬시킨다.
그러면 점들을 순서대로 방문했을 때, 현재 점 (x,y)에서 이전에 나온 어떤 점 (p,q)로 갈 수 있으려면?
y-x >= q-p이거나 y+x >= q+p여야 한다.
두 개의 세그를 만들어서 한 쪽에는 y-x, 다른 한 쪽에는 y+x 인덱스에 각각 해당 점에서의 답을 기록해놓고 max seg를 구성해서 모든 점에 대한 답을 구해줬다.
⏳ 회고
좌표 범위가 너무 커서 압축한 뒤에 이분 탐색으로 인덱스를 구해줬는데,
이분 탐색할 때 부등호 방향을 반대로 해줘서 계속 틀림.
이런 실수 못 찾을 때마다 멘탈이 갈린다...