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/18869
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
M개의 우주가 있고, 각 우주에는 1~N번 행성이 있다. 행성의 크기를 알 때, 균등한 우주의 쌍이 몇 개인지 구하라.
$1 \leq i, j \leq N$ 에 대하여
균등의 조건
🔍 풀이 방법
좌표를 압축해야 한다. 좌표를 압축하고, 각 우주 중 2개를 선택하고 1~N번 행성의 랭킹을 쭉 탐색하면,$M^{2}N$ 의 시간복잡도면 얼추 1억이기 때문에 2초만에 실행 가능하다.
이 때, 1~N번 행성의 랭킹을 찾는 방법은 이분탐색을 사용한다.
⏳ 회고
여기서 이분탐색을 사용한다니, 진짜 몰랐다. 아직 한참 멀었다. G선생이 없었다면, 못 풀었겠네.