[Programmers] 등교길

Time Lapse :1hour 2min 0sec

solution.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <string>
#include <vector>
#include <memory.h>
#include <iostream>
using namespace std;
//1:02:00
int solution(int m, int n, vector<vector<int>> puddles) {
int MAP[101][101] = {0,};
int DP[101][101];
for(int i=0;i<puddles.size();i++){
MAP[puddles[i][1]][puddles[i][0]] = -1;}
DP[0][1]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(MAP[i][j]==-1)
DP[i][j]=0;
else
DP[i][j] = (DP[i-1][j]+DP[i][j-1])%1000000007;
}
}
return DP[n][m];
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/Programmers/schoolRoad/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.