Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-10-04] sumin #298 #328

Merged
merged 1 commit into from
Mar 18, 2024
Merged

[2023-10-04] sumin #298 #328

merged 1 commit into from
Mar 18, 2024

Conversation

ksumini
Copy link
Contributor

@ksumini ksumini commented Oct 9, 2023

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가 다른 문제들과 달리 반대로 나와있어서 시간을 한참 썼다 😐

@ksumini
Copy link
Contributor Author

ksumini commented Oct 9, 2023

늦게 올려서 죄송합니당....😭

@ksumini ksumini linked an issue Oct 9, 2023 that may be closed by this pull request
Copy link
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

매트릭스에 패딩을 적절하게 적용하셔서 하나의 점화식으로 문제를 깔끔하게 해결하신 점이 좋았던 코드였습니다! 이번 문제를 계기로 저도 적절하게 패딩을 활용하는 습관을 가져야겠어요! 이런 경우가 생각보다 많네요! 고생하셨습니다 수민님!

O(NM)

<번외>
puddles의 x,y가 다른 문제들과 달리 반대로 나와있어서 시간을 한참 썼다..😐
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

후.. 진짜 저도 딥빡 했습니다

@zsmalla zsmalla merged commit dc33513 into main Mar 18, 2024
@zsmalla zsmalla deleted the sumin-#298 branch March 18, 2024 10:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Programmers] 등굣길
2 participants