[20250814] BOJ / D5 / 플러드 필 (Flood Fill) / 권혁준#665
Merged
ShinHeeEul merged 1 commit intomainfrom Aug 14, 2025
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/6181
🧭 풀이 시간
180분
👀 체감 난이도
✏️ 문제 설명
2차원 좌표평면에 N개의 점이 주어진다.
두 점 사이의 맨해튼 거리가 D 이하면 두 점을 잇는 간선이 존재한다.
컴포넌트의 개수와 컴포넌트에 속한 점 수의 최댓값을 구해보자.
🔍 풀이 방법
고개를 45도만 돌려서 문제를 보면, 각 점 (x,y)는 (y+x, y-x)가 된다.
그러면 어떤 점 (x, y)에 대해, 그 점을 중심으로 갖고 변의 길이가 2D인 정사각형 내에 속하는 점들을 찾으면 된다.
D가 고정된 값이니까, 일단 점들을 x축 기준으로 정렬시켜놓고 set에는 y좌표 기준으로 정렬되도록 세팅한다.
각 점을 방문할 때마다, set에서 양 옆으로 인접한 y좌표를 갖는 점들과 union한다.
그리고 이 점을 set에서 제거해야 하는 시기 (x좌표 차이가 D를 넘어갈 때)를 또다른 set에서 관리한다.
이런 식으로 모든 점들 사이의 연결 관계를 나타낼 수 있고, 마지막에 한 번 순회하며 답을 구했다.
⏳ 회고
너무고통스러웠다