Submission #1339652

#TimeUsernameProblemLanguageResultExecution timeMemory
1339652iamhereforfun캥거루 (CEOI16_kangaroo)C++20
0 / 100
1 ms344 KiB
// Starcraft 2 enjoyer //

#include <bits/stdc++.h>

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

#define LSOne(X) ((X) & -(X))

const int N = 2e3 + 5;
const int K = 1e2 + 5;
const int LG = 20;
const int INF = 1e9 + 5;
const int B = 1000;
const int MOD = 1e9 + 7;

int n, a, b;
long long dp[N][N];

inline void solve()
{
    cin >> n >> a >> b;
    dp[0][0] = 1;
    for (int x = 1; x <= n; x++)
    {
        for (int y = 0; y <= x; y++)
        {
            if (x == a || x == b)
            {
                dp[x][y] = dp[x - 1][y];
            }
            else
            {
                dp[x][y] += 1LL * (y - 1) * dp[x - 1][y + 1];
                if (y > 0)
                    dp[x][y] += 1LL * (y + 1) * dp[x - 1][y - 1];
                dp[x][y] += 1LL * y * dp[x - 1][y];
            }
            dp[x][y] %= MOD;
            // cout << dp[x][y] << " ";
        }
        // cout << "\n";
    }
    cout << dp[n][1] << "\n";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    for (int x = 1; x <= t; x++)
    {
        solve();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...