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;
const int mod = 1e9 + 7;
int n, s, t, f[2010][2010];
signed main() {
cin >> n >> s >> t;
f[1][1] = 1;
for (int i = 2; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (i != s && i != t)
f[i][j] = (j * (f[i - 1][j + 1]) % mod + (j - (i > s) - (i > t)) * f[i - 1][j - 1] % mod) % mod;
else
f[i][j] = f[i - 1][j - 1] + f[i - 1][j];
}
}
cout << f[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... |