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;
#define int long long
const int mod =1000000007;
int dp[3000][3000];
signed main(){
int n,st,fs;
cin >> n >> st >> fs;
dp[1][1] = 1;
for(int i=2;i<=n;++i){
if(i == st || i == fs){
for(int j=1;j<=n;++j){
dp[i][j] = ((dp[i-1][j-1] + dp[i-1][j]) % mod);
}
continue;
}
for(int j=1;j<=n;++j){
//x _ x _ x
dp[i][j] = (dp[i-1][j+1] * j) % mod;
dp[i][j] = (dp[i][j] + ((dp[i-1][j-1] * j) % mod)) % mod;
}
}
cout << dp[n][n] / 2;
}
# | 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... |