-
algospot - jumpgameAlgorithm/알고스팟 2020. 2. 2. 14:361234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950//algospot - jumpgame#include <bits/stdc++.h>using namespace std;int N;vector<vector<int>> arr;vector<vector<int>> mem;void init(){cin >> N;arr = vector<vector<int>>(N, vector<int>(N));mem = vector<vector<int>>(N, vector<int>(N, -1));for(int i = 0; i<N; ++i)for(int j = 0; j<N; ++j)cin >> arr[i][j];}int dp(int x, int y){if(x == N-1 && y == N-1)return 1;int& ret = mem[x][y];if(ret != -1)return ret;ret = 0;int num = arr[x][y];if(x + num < N)ret += dp(x+num, y);if(y + num < N)ret += dp(x, y+num);return ret;}int main(){ios_base::sync_with_stdio(0); cin.tie(0);int C; cin >> C;for(int tn = 0; tn < C; ++tn){init();int flag = dp(0, 0);if(flag)cout << "YES" << "\n";elsecout << "NO" << "\n";}}
cs https://www.algospot.com/judge/problem/read/JUMPGAME
algospot.com :: JUMPGAME
외발 뛰기 문제 정보 문제 땅따먹기를 하다 질린 재하와 영훈이는 땅따먹기의 변종인 새로운 게임을 하기로 했습니다. 이 게임은 그림과 같이 n*n 크기의 격자에 각 1부터 9 사이의 정수를 쓴 상태로 시작합니다. 각 차례인 사람은 맨 왼쪽 윗 칸에서 시작해 외발로 뛰어서 오른쪽 아래 칸으로 내려가야 합니다. 이 때 각 칸에 적혀 있는 숫자만큼 오른쪽이나 아래 칸으로 움직일 수 있으며, 중간에 게임판 밖으로 벗어나면 안 됩니다. 균형을 잃어서 다른 발로 서거
www.algospot.com
DP문제
'Algorithm > 알고스팟' 카테고리의 다른 글
algospot - trianglepath (0) 2020.02.02 algospot - wildcard (0) 2020.02.02 algospot - lan (0) 2020.01.31 algospot - promises (0) 2020.01.29 algospot - drunken (0) 2020.01.29