This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mod 1000000007
#define MAXN 2010
#define int long long
void solve() {
ll n, s , e;
cin >> n >> s >> e;
ll dp[n+10][n+10] = {0};
dp[1][1] = 1;
for(int i = 2;i<=n;i++) {
for(int j = 1;j<=i;j++) {
if(i == s or i == e) {
dp[i][j] = (dp[i-1][j-1]+dp[i-1][j])%mod;
}
else {
dp[i][j] = (dp[i-1][j+1]*j%mod + dp[i-1][j-1] * (j - (s<i) - (e<i))%mod)%mod;
}
}
}
cout<<dp[n][1]<<endl;
}
int32_t main () {/*
#ifndef ONLINE_JUDGE
freopen("stdin", "r", stdin);
freopen("stdout", "w", stdout);
freopen("stderr", "w", stderr);
#endif*/
//cin >> t;
solve();
return 0;
}
# | 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... |