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;
signed main(){
int n,st,fs;
int cnt=0;
cin >> n >> st >> fs;
vector<vector<int>> dp(n+5,vector<int>(n+5,0));
dp[1][1] = 1;
for(int i=2;i<=n;++i){
for(int j=1;j<=n;++j){
if(i == st || i == fs){
cnt++;
dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]) % mod;
continue;
}
dp[i][j] = (((dp[i-1][j+1] * j) % mod) + ((((dp[i-1][j-1] * ( j - cnt)) % mod) + mod) % mod)) % mod;
}
}
cout << dp[n][1];
//2 4 1 5 3
//2 5 1 4 3
}
# | 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... |