#include <iostream>
#include <cstring>
using namespace std;
using ll = long long;
int map[100][100];
ll cache[100][100];
int n;
ll bf(int x, int y){
if((x == n-1) && (y == n-1)) return 1;
ll& ret = cache[x][y];
if(ret != -1) return ret;
ret = 0;
if(x + map[x][y] < n) ret += bf(x + map[x][y], y);
if(y + map[x][y] < n) ret += bf(x, y + map[x][y]);
return ret;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
memset(cache, -1, sizeof(cache));
cin >> n;
for(int i = 0 ; i < n; ++i)
for(int j = 0; j < n; ++j)
cin >> map[i][j];
cout << bf(0, 0);
}
백준 1916 최소비용 구하기 혼내주기 (0) | 2021.08.02 |
---|---|
백준 11729 하노이 탑 이동 순서 혼내주기 (0) | 2021.08.02 |
백준 4485 녹색 옷 입은 애가 젤다지? 혼내주기 (0) | 2021.08.02 |
백준 1918 후위 표기식 혼내주기 (0) | 2021.08.02 |
백준 9465 스티커 혼내주기 (0) | 2021.08.02 |
댓글 영역