#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD=1e9L+7LL;
#define MAXN 2020
ll dp[MAXN][MAXN][2];
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, cs, cf;
cin >> n >> cs >> cf;
--n;
if(cf<cs) --cs;
--cs;
dp[1][0][0]=dp[1][0][1]=1;
for(int i=2;i<=n;i++) {
dp[i][0][0]=0;
for(int j=1;j<i;j++) dp[i][j][0]=(dp[i][j-1][0]+dp[i-1][j-1][1])%MOD;
dp[i][i-1][1]=0;
for(int j=i-2;j>=0;j--) dp[i][j][1]=(dp[i][j+1][1]+dp[i-1][j][0])%MOD;
}
cout << (dp[n][cs][0]+dp[n][cs][1])%MOD << endl;
}
| # | 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... |