[20250308] BOJ / G3 / 인지융~ / 권혁준 #216
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/24727
🧭 풀이 시간
25분
👀 체감 난이도
✏️ 문제 설명
N*N 격자에
1을 C개,2를 E개 배치해보자.같은 숫자끼리는 서로 연결되어야 하고, 다른 숫자끼리는 인접하면 안 된다.
🔍 풀이 방법
[사용한 알고리즘]
위와 같이, 초록을 1개 배치해야 하는 상황이라면 빨강은 최대 N*N-3개까지 배치할 수 있다.
여기서 초록의 개수가 하나 늘어나게 되면, 빨강은 두 개를 희생해야 한다.
초록이 하나 더 늘어나면? 빨강은 하나만 희생해도 된다.
이런 식으로 계속 생각을 이어가면, 각각 양쪽 꼭짓점에서 출발해서 계단식 배치를 하며 채워나가는 것이 항상 효율적인 배치임을 알 수 있다.
⏳ 회고
옛날에 못 풀었던 문제였는데 풀어서 기분이 좋다