[20250320] BOJ / G3 / A Knightly Pursuit / 권혁준 #274
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/6957
🧭 풀이 시간
56분

👀 체감 난이도
✏️ 문제 설명
R*C 격자판에 나이트와 폰 하나가 있다.
나이트가 폰을 몇 번 만에 잡을 수 있는지 구해보자.
못 잡는다면, 몇 번 만에 stalemate가 날 수 있는지 구해보자.
그것도 안 된다면, 몇 번 만에 게임에서 지게 되는지 구해보자.
🔍 풀이 방법
[사용한 알고리즘]
나이트가 각 칸에 도달할 수 있는 최단 시간을 BFS로 구한다.
또, 나이트 이동 성질에 의해, 시간 t에 어떤 칸에 도달했다면 t+2, t+4, t+6, ...에도 도달 가능하다.
이걸 가지고 잘 판별해주면 된다.
⏳ 회고
한 번 갔던 칸을 또 갈 수 있는 걸 너무 늦게 생각했다.