#include <vector>
#include <cstring>
using namespace std;
const int MAX = 501;
int MOD = 20170805;
int top[MAX][MAX],lefts[MAX][MAX];
int solution(int m, int n, vector<vector<int>> city_map) {
memset(top,0,sizeof(top));
memset(lefts,0,sizeof(lefts));
top[1][1] = lefts[1][1] = 1;
for(int i=1; i<=m; i++){
for(int j=1; j<=n; j++){
if(city_map[i-1][j-1] == 0){
top[i][j] += (top[i-1][j] + lefts[i][j-1])%MOD;
lefts[i][j] += (top[i-1][j] + lefts[i][j-1])%MOD;
}
else if(city_map[i-1][j-1] == 1){
top[i][j] = 0;
lefts[i][j] = 0;
}
else{
top[i][j] = top[i-1][j];
lefts[i][j] = lefts[i][j-1];
}
}
}
return top[m][n]%MOD;
}
'프로그래머스' 카테고리의 다른 글
서울에서 경산까지 C++ (0) | 2019.10.09 |
---|---|
카드 게임 C++ (0) | 2019.10.09 |
순위 C++ (0) | 2019.09.30 |
저울 C++ (0) | 2019.09.30 |
이중우선순위큐 C++ (0) | 2019.09.29 |