[20250907] BOJ / P5 / 폭탄 던지는 태영이 / 권혁준 #837
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/20543
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
NN크기의 격자 내에 폭탄이 설치되어 있다.
(i,j)에 위치한 폭탄이 k개이면, (i,j)를 중심으로 하는 MM 정사각형 범위의 고도가 k만큼 깎인다.
깎인 고도 배열이 주어지면, 각 칸에 폭탄이 몇 개 있는지 구해보자.
🔍 풀이 방법
어떤 칸 (i,j)에 추가된 폭탄이 k개면, (i+1, j)와 (i, j+1)에 k개가 추가되어야 하고, (i+M, j)와 (i, j+M)에는 k개가 제거되어야 한다. -> 2차원 imos법으로 해결했다.
중복 추가를 방지하기 위해 (i+1,j+1)에는 k개를 빼주고 (i+M, j+M)에는 k개를 더해줬다.
⏳ 회고
2차원이라 좀 힘들었다