Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
[2023-10-04] sumin #298 - #328
Merged
Merged
Conversation
ksumini
requested review from
Woo-Yeol, limstonestone and zsmalla
as code ownersOctober 9, 2023 13:49
ksumini
commented
Oct 9, 2023
ContributorAuthor
늦게 올려서 죄송합니당....😭 |
Closed
zsmalla
approved these changes
Oct 12, 2023
zsmalla
left a comment
Contributor
There was a problem hiding this comment.
매트릭스에 패딩을 적절하게 적용하셔서 하나의 점화식으로 문제를 깔끔하게 해결하신 점이 좋았던 코드였습니다! 이번 문제를 계기로 저도 적절하게 패딩을 활용하는 습관을 가져야겠어요! 이런 경우가 생각보다 많네요! 고생하셨습니다 수민님!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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가 다른 문제들과 달리 반대로 나와있어서 시간을 한참 썼다 😐