[20251021] BOJ / P4 / 경로 수정하기 / 권혁준 #1189
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/20554
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
(0,0)에서 출발하여 상하좌우 중 하나로 구성된 길이 N의 이동 명령을 따라 이동한다.
도착점이 (x,y)가 되기 위해 수정해야 하는 이동 명령의 최솟값을 Q번 구해보자.
🔍 풀이 방법
새로운 도착점 (x,y)는 원래의 도착점 (X,Y)와 체스판 상에서 다른 색 칸에 위치한다면 절대 이동할 수 없다.
또, |x| + |y|가 N보다 크면 어떻게 수정해도 이동할 수 없다.
위 두 경우를 배제하면 답은 (|x-X| + |y-Y|) / 2라고 생각했다.
⏳ 회고
근데 답이 저게 아닌가보다. 왜 아니지? 반례도 못 찾겠음