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
int dp[2005][2005];
const int MOD = 1000000007;
int32_t main() {
int n, start, end;
cin >> n >> start >> end;
dp[1][1] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i == 1 and j == 1) dp[i][j] = 1;
else if (i == 1) {dp[i][j] = 0; continue;}
else if (i != start and i != end) {
dp[i][j] = (int)(dp[i-1][j+1]*j)%MOD;
int k = j;
if (i > start) k -= 1;
if (i > end) k -= 1;
dp[i][j] += (int)(dp[i-1][j-1] * k)*MOD;
}
else {
dp[i][j] = dp[i-1][j-1];
dp[i][j]%=MOD;
dp[i][j] += dp[i-1][j];
dp[i][j]%=MOD;
}
}
}
cout << dp[n][1] << "\n";
}
# | 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... |