public int solution(int m, int n, int[][] cityMap) {
int[][][] dp = new int[m + 1][n + 1][2];
final int mod = 20170805;
dp[0][0][0] = 1;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
switch (cityMap[i][j]) {
case 0:
dp[i + 1][j][0] += (dp[i][j][0] + dp[i][j][1]) % mod;
dp[i][j + 1][1] += (dp[i][j][0] + dp[i][j][1]) % mod;
break;
case 2:
dp[i + 1][j][0] += dp[i][j][0] % mod;
dp[i][j + 1][1] += dp[i][j][1] % mod;
break;
default:
break;
}
}
}
return (dp[m - 1][n - 1][0] + dp[m - 1][n - 1][1]) % mod;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/1832