#include<bits/stdc++.h>
#include<algorithm>
#include<random>
#include<chrono>
#include<cstdlib>
#include<ctime>
#include<numeric>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#define int long long
#define ll long long
#define L LLONG_MAX
#define fi first
#define se second
#define pii pair<int,int>
#define sz(a) ((int)a.size())
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REP(i,k,j) for(int i=k;i>=j;i--)
#define FORD(i,a) for(auto i:a)
#define rngdcl mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(l,r) ((l)+(rng()%(r-l+1)))
using namespace std;
const int mod=1e9+7;
const int nmax=2001;
int n,st,ed;
int dp[nmax][nmax];
void input()
{
cin >> n >> st >> ed;
}
void solve()
{
dp[1][1]=1;
FOR(i,2,n)
{
if(i==st || i==ed)
{
FOR(j,1,i)
{
dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
}
}
else
{
FOR(j,1,i)
{
dp[i][j]=(dp[i][j]+j*dp[i-1][j-1])%mod;
if(i>st) dp[i][j]=(dp[i][j]-dp[i-1][j-1])%mod;
if(i>ed) dp[i][j]=(dp[i][j]-dp[i-1][j-1])%mod;
dp[i][j]=(dp[i][j]+j*dp[i-1][j+1])%mod;
}
}
}
// FOR(i,1,n) {FOR(j,1,n) cout << dp[i][j] << ' '; cout << '\n';}
cout << (dp[n][1]%mod+mod)%mod;
}
signed main()
{
//freopen("kangaroo.in", "r", stdin);
//freopen("kangaroo.out", "w", stdout);
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
input();
solve();
}
# | 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... |