# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316932 | Kuuhaku | Kangaroo (CEOI16_kangaroo) | C++17 | 91 ms | 14200 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.
#define tasknames "Kangaroo"
#include <iostream>
#include <stdio.h>
using namespace std;
const int maxn=2e3+2;
int n, cs, cf, dp[maxn][maxn], mod=1e9+7;
void Enter()
{
cin>>n>>cs>>cf;
if(cs>cf)swap(cs,cf);
dp[1][0]=1;
for(int i=1;i<=n;i++)
for(int j=0;j<=i;j++)
{
if(i==cs||i==cf)
{
dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
if(j)dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*dp[i][j]%mod)%mod;
}
else
{
if(i>cf)
dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*dp[i][j]%mod)%mod;
if(i>cs)
dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*dp[i][j]%mod)%mod;
dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*(j-1)*dp[i][j]%mod)%mod;
}
}
cout<<dp[n][0];
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if(fopen(tasknames".INP","r"))
{
freopen(tasknames".INP","r",stdin);
freopen(tasknames".OUT","w",stdout);
}
Enter();
}
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... |