Submission #635817

#TimeUsernameProblemLanguageResultExecution timeMemory
635817zeroesandonesJump (BOI06_jump)C++17
70 / 100
1 ms340 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vi; typedef pair<ll, ll> pi; #define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i) #define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i) #define nl "\n" #define all(x) (x).begin(), (x).end() #define sc second #define fr first #define pb push_back string add(string a, string b) { if(a.length() < b.length()) swap(a, b); while(b.length() < a.length()) b = "0" + b; string ans; int carry = 0; FORD(i, a.length() - 1, 0) { int c = (a[i] - '0') + (b[i] - '0') + carry; char num = (char) (c % 10 + (int)('0')); ans = num + ans; carry = c / 10; } if(carry) { char num = (char) (carry + (int)('0')); ans = num + ans; } return ans; } void solve() { int n; cin >> n; int a[n][n]; FOR(i, 0, n){ FOR(j, 0, n) { cin >> a[i][j]; } } ll dp[n][n] = {}; dp[0][0] = 1; FOR(i, 0, n) { FOR(j, 0, n) { if(a[i][j] == 0) continue; if(i + a[i][j] < n) dp[i + a[i][j]][j] += dp[i][j]; if(j + a[i][j] < n) dp[i][j + a[i][j]] += dp[i][j]; } } // FOR(i, 0, n) { // FOR(j, 0, n){ // cout << dp[i][j] << " "; // } // cout << nl; // } cout << dp[n - 1][n - 1] << nl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t = 1; // cin >> t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...