No Rules Rules

점프 (feat. 백준, 1890번) 본문

생활/코테

점프 (feat. 백준, 1890번)

개발하는 완두콩 2022. 9. 6. 16:55
728x90
반응형

점프
https://www.acmicpc.net/problem/1890

 

1890번: 점프

첫째 줄에 게임 판의 크기 N (4 ≤ N ≤ 100)이 주어진다. 그 다음 N개 줄에는 각 칸에 적혀져 있는 수가 N개씩 주어진다. 칸에 적혀있는 수는 0보다 크거나 같고, 9보다 작거나 같은 정수이며, 가장

www.acmicpc.net

 

반응형

 

// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL);
	register int N;
	int arr[101][101];
	long long dp[101][101];
	cin >> N;
	for (register int i = 1, j; i <= N; ++i)
		for (j = 1; j <= N; ++j)
			cin >> arr[i][j], dp[i][j] = 0;
	dp[1][1] = 1;
	for (register int x = 1, y; x <= N; ++x)
		for (y = 1; y <= N; ++y) {
			if ((x == N && y == N) || (dp[x][y] == 0))
				continue;
			register int dist = arr[x][y];
			register int down = x + dist;
			register int right = y + dist;
			if (down <= N)
				dp[down][y] = dp[down][y] + dp[x][y];
			if (right <= N)
				dp[x][right] = dp[x][right] + dp[x][y];
		}
	cout << dp[N][N] << "\n";
	return 0;
}
// *&)*@*

 

해당 문제는 아래 "Pascal's Travels" 와 동일한 문제입니다.

 

Pascal's Travels (feat. 백준, 4620번)

Pascal's Travels https://www.acmicpc.net/problem/4620 4620번: Pascal's Travels The input contains data for one to thirty boards, followed by a final line containing only the integer -1. The data for..

kim519620.tistory.com

 

 

728x90
반응형
Comments