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 = 1e9 + 7;
int dp[2001][2001];
void solve()
{
int n, cf, cn, cnt = 0;
cin >> n >> cf >> cn;
dp[1][1] = 1;
for(int i = 1; i <= n; i++)
{
if(i == cf || i == cn)
cnt++;
for(int j = 1; j < i; j++)
{
if(i == cf || i == cn)
{
dp[i][j] += (dp[i - 1][j]) % mod;
dp[i][j + 1] += (dp[i - 1][j] % mod);
}
else
{
dp[i][j + 1] += (dp[i - 1][j] * (j + 1 - cnt)) % mod;
dp[i][j - 1] += (dp[i - 1][j] * (j - 1)) % mod;
}
}
}
cout << dp[n][1] << endl;
}
signed main()
{
int tt = 1;
// cin >> tt;
while(tt--)
solve();
}
# | 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... |