제출 #1339663

#제출 시각아이디문제언어결과실행 시간메모리
1339663iamhereforfun캥거루 (CEOI16_kangaroo)C++20
100 / 100
28 ms31812 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 = 1; y <= n; y++)
        {
            if (x == a || x == b)
            {
                dp[x][y] += dp[x - 1][y] + dp[x - 1][y - 1];
            }
            else
            {
                // dp[x][y] += y * dp[x - 1][y];
                dp[x][y] += (y - (x > a) - (x > b)) * dp[x - 1][y - 1];
                dp[x][y] += y * dp[x - 1][y + 1];
            }
            dp[x][y] %= MOD;
            // cout << dp[x][y] << " ";
        }
        // cout << "\n";
    }
    cout << dp[n][1] << "\n";
}

signed main()
{
    // freopen("CP.INP", "r", stdin);
    // freopen("CP.OUT", "w", stdout);
    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...