# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
683428 | lam | Kangaroo (CEOI16_kangaroo) | C++14 | 20 ms | 22984 KiB |
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 int long long
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2010;
int n,s,f;
int dp[maxn][maxn];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cin>>n>>s>>f;
dp[0][0]=1LL;
for (int i=1; i<=n; i++)
for (int j=1; j<=i; j++)
{
if (i==s)
{
dp[i][j]=(dp[i-1][j] + dp[i-1][j-1])%mod;
}
else if (i==f)
{
dp[i][j]=(dp[i-1][j] + dp[i-1][j-1])%mod;
}
else
{
dp[i][j]=(j) * dp[i-1][j+1]%mod;
int val = j-2;
if (i<s) val++; if (i<f) val++;
dp[i][j] = (dp[i][j] + val*dp[i-1][j-1]%mod)%mod;
}
}
cout<<dp[n][1]<<'\n';
}
Compilation message (stderr)
# | 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... |