# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
284542 | Pyqe | Kangaroo (CEOI16_kangaroo) | C++14 | 31 ms | 384 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>
using namespace std;
long long n,st,fn,dp[2][2069],dv=1e9+7;
int main()
{
long long i,j,r,c=0;
scanf("%lld%lld%lld",&n,&st,&fn);
dp[0][0]=1;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i!=st&&i!=fn)
{
dp[1][j]=(dp[0][j-1]*(j-c)+dp[0][j+1]*j)%dv;
}
else
{
dp[1][j]=dp[0][j];
dp[1][j]=(dp[1][j]+dp[0][j-1])%dv;
}
}
c+=i==st||i==fn;
for(j=0;j<=n;j++)
{
dp[0][j]=dp[1][j];
dp[1][j]=0;
}
}
printf("%lld\n",dp[0][1]);
}
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... |