Submission #1327198

#TimeUsernameProblemLanguageResultExecution timeMemory
1327198HaroldVemenoKangaroo (CEOI16_kangaroo)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h>

#ifdef GUDEB
    #define D(x) cerr << #x << ": " << (x) << '\n';
    #define ifdeb if(true)
#else
    #define D(x) ;
    #define ifdeb if(false)
#endif

#define all(x) begin(x), end(x)

using namespace std;
using ull = unsigned long long;
using ll = long long;
// #define int ll;

constexpr ll mod = 1000000007;

int dp1[2002][2002];
int dp2[2002][2002];

void solve() {
    int n, s, f;
    cin >> n >> s >> f;
    --s; --f;

    int (*dp)[2002][2002] = &dp1;
    int (*ndp)[2002][2002] = &dp2;

    (*dp)[s][f] = 1;
    (*dp)[n-s-1][n-f-1] = 1;
    for(int i = n-1; i >= 1; --i) {
        for(int f = 0; f < i; ++f) {
            ll d = 0;
            for(int s = 0; s < i; ++s) {
                d += (*dp)[s][f + (f <= s)];
                d %= mod;
                (*ndp)[i-1-s][i-1-f] += d;
                (*ndp)[i-1-s][i-1-f] %= mod;
            }
        }
        swap(dp, ndp);
        for(int f = 0; f < i; ++f) {
            for(int s = 0; s < i; ++s) {
                (*ndp)[f][s] = 0;
            }
        }
    }
    cout << (*dp)[0][0] << '\n';


}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(20);

    solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...