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>
#define fin std::cin
#define fout std::cout
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
int n, start, stop, flag = 0;
fin >> n >> start >> stop;
long long mod = 1000000007;
long long dp[n+2][n+2] = {};
dp[0][0] = 1;
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= i; j ++) {
if(i == start or i == stop) {
flag ++;
dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]) % mod;
continue;
}
dp[i][j] = (dp[i-1][j-1] * (j - flag) + dp[i-1][j+1] * j) % mod;
}
}
fout << dp[n][1] << '\n';
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... |