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
#define N 2005
int md = 1e9 + 7, dp[N][N], cf, cs, n;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n >> cs >> cf;
dp[1][1] = 1;
for (int i = 2; i <= n; i++){
for (int j = 1; j <= n; j++){
if (i == cs || i == cf){
dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % md;
continue;
}
dp[i][j] = dp[i - 1][j - 1] * (j - (j > cs) - (j > cf)) % md;
dp[i][j] = dp[i - 1][j + 1] * j % md;
}
}
cout << dp[n][1];
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... |