#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
// #pragma GCC target("avx2")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define all(v, l) v.begin() + l, v.end()
#define rall(v, l) v.rbegin(), v.rend() - l
#define pb push_back
#define pf push_front
#define rsz resize
#define fi first
#define se second
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define endl "\n"
#define newline cout << endl;
using namespace std;
const ll MOD = 1000000007;
// structs
// globals
// variables
int n, s, e;
// iterators
int i, j;
// notes
/*
-stuff you should look for-
* int overflow, array bounds
* special cases (n=1?)
* do something instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
continue - skip the rest in the loop
*/
// functions
ll GCD(ll numeroune, ll numerodeux);
ll LCM(ll numeroune, ll numerodeux);
ll power(ll numeroune, ll numerodeux);
void solve()
{
cin >> n >> s >> e;
vector <vector <ll> > dp(n + 1, vector <ll>(n + 2));
dp[1][1] = 1LL;
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
if (i == s || i == e)
{
dp[i][j + 1] = (dp[i][j + 1] + dp[i - 1][j]) % MOD;
dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
}
else
{
dp[i][j + 1] = (dp[i][j + 1] + ((dp[i - 1][j] * 1LL * (j + 1 - (i >= s) - (i >= e))) % MOD)) % MOD;
dp[i][j - 1] = (dp[i][j - 1] + ((dp[i - 1][j] * 1LL * (j - 1)) % MOD));
}
}
}
cout << dp[n][1];
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
solve();
newline
}
}
ll GCD(ll numeroune, ll numerodeux)
{
if (!numeroune)
{
return numerodeux;
}
return GCD(numerodeux % numeroune, numeroune);
}
ll LCM(ll numeroune, ll numerodeux)
{
return numeroune * numerodeux / GCD(numeroune, numerodeux);
}
ll power(ll numeroune, ll numerodeux)
{
ll res = 1;
while (numerodeux)
{
if (numerodeux & 1)
{
res *= numeroune;
}
numeroune *= numeroune;
numerodeux >>= 1;
}
return res;
}
/*
$$$$$$$$\ $$$$$$$$\
$$ _____|\____$$ |
$$ | $$ /
$$$$$\ $$ /
$$ __| $$ /
$$ | $$ /
$$$$$$$$\ $$$$$$$$\
\________|\________|
*/
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |