제출 #1347833

#제출 시각아이디문제언어결과실행 시간메모리
1347833BlockOGJump (BOI06_jump)C++20
100 / 100
3 ms2116 KiB
#include <bits/stdc++.h>

// mrrrowwww meeowwwww :3
// go play vivid/stasis! !! !!! https://vividstasis.gay

#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;

int ____init = []{
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    return 0;
}();

struct BigInt {
    vector<int> v;
    BigInt() : v { 0 } {}
};

ostream &operator<<(ostream &out, const BigInt &v) {
    of(i, 0, v.v.size()) out << v.v[i];
    return out;
}

void operator+=(BigInt &l, const BigInt &r) {
    while (l.v.size() < r.v.size()) l.v.pb(0);
    l.v.pb(0);

    int i = 0;
    for (; i < r.v.size(); i++) {
        l.v[i] += r.v[i];
        if (l.v[i] >= 10) l.v[i] -= 10, l.v[i + 1]++;
    }
    while (l.v[i] >= 10) l.v[i] -= 10, l.v[++i]++;

    while (l.v.size() > 1 && l.v.back() == 0) l.v.pop_back();
}

int jump[100][100];
BigInt dp[100][100];

int main() {
    int n; cin >> n;
    fo(i, 0, n) fo(j, 0, n) cin >> jump[i][j];

    dp[0][0].v = { 1 };
    fo(i, 0, n) fo(j, 0, n) {
        if (jump[i][j] <= 0) continue;
        if (i + jump[i][j] < n) dp[i + jump[i][j]][j] += dp[i][j];
        if (j + jump[i][j] < n) dp[i][j + jump[i][j]] += dp[i][j];
    }

    cout << dp[n - 1][n - 1];
}
#Verdict Execution timeMemoryGrader output
Fetching results...