#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, k;
// 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
dp[a][b][c] represents the number of ways to come to path a in b turns, jumping (c == 0 ? down : up)
k - turn
*/
// 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 <vector <ll> > > dp(n + 1, vector <vector <ll> > (n, vector <ll> (2, 0LL)));
vector <ll> pf0(n + 1), pf1(n + 1);
dp[s][1][1] = dp[s][1][0] = 1LL;
for (k = 2; k <= n; k++)
{
for (i = 1; i <= n; i++)
{
pf0[i] = (pf0[i - 1] + dp[i][k - 1][0]) % MOD;
pf1[i] = (pf1[i - 1] + dp[i][k - 1][1]) % MOD;
}
for (i = 1; i <= n; i++)
{
dp[i][k][0] = pf1[i - 1];
dp[i][k][1] = (pf0[n] - pf0[i]) % MOD;
}
}
cout << (dp[e][n][0] + dp[e][n][1]) % MOD;
}
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... |