This repository was archived by the owner on Mar 18, 2024. It is now read-only.
[2023-10-04] sumin #298 #328
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.
PR Summary
풀이시간: 25분
<input>
m: 가로의 크기(1 <= m <= 100, 자연수)
n: 세로의 크기(1 <= n <= 100, 자연수)
puddles: 물이 잠긴 지역의 좌표를 담은 2차원 배열(0개 이상 10개 이하)
<solution>
BFS인가? 싶었는데 우선 큰 수(1,000,000,007)로 경우의 수를 나누는걸 보면 DP라고 생각하고 접근
dp[i][j] = (i, j)칸까지 최단경로의 경우의 수 라고 한다면, 항상 오른쪽 또는 아래로만 이동하기 때문에
위에서 오는 경우의 수(dp[i-1][j]) + 오른쪽에서 오는 경우의 수(dp[i][j-1])가 dp[i][j]의 값이 될 수 있다.
이 때, 수가 너무 커지지 않게 하기 위해 항상 1,000,000,007로 나눈 나머지 수를 테이블에 기록한다.
<시간복잡도>
O(NM)
<번외>
puddles의 x,y가 다른 문제들과 달리 반대로 나와있어서 시간을 한참 썼다 😐