제출 #1210022

#제출 시각아이디문제언어결과실행 시간메모리
1210022i_love_springJump (BOI06_jump)C++20
5 / 100
1096 ms488 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array void solve() { int n; cin >> n; vector<vector<int>> a(n + 1,vector<int>(n + 1)); vector<vector<ll>> dp(n + 1,vector<ll>(n + 1, 0)); for (int i = 1;i <= n;i++) { for (int j = 1; j <= n;j++) cin >> a[i][j]; } if (a[n][n] != 0) { cout << 0; return; } dp[1][1] = 1; function<void(int,int)> dfs = [&](int x,int y) { if (a[x][y] == 0) return; if (x + a[x][y] <= n) { dp[x + a[x][y]][y] += dp[x][y]; dfs(x + a[x][y],y); } if (y + a[x][y] <= n) { dp[x][y + a[x][y]] += dp[x][y]; dfs(x, y + a[x][y]); } }; dp[1][1] = 1; dfs(1,1); cout << dp[n][n]; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...