# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771715 | Amylopectin | Kangaroo (CEOI16_kangaroo) | C++14 | 20 ms | 24004 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 <stdio.h>
#include <iostream>
using namespace std;
const long long mxn = 3e3 + 10,mo = 1e9 + 7;
long long dp[mxn][mxn] = {};
int main()
{
long long i,j,n,m,stt,enn,cap,cou = 0;
scanf("%lld %lld %lld",&n,&stt,&enn);
dp[0][0] = 1;
cap = n/2 + 2;
for(i=1; i<=n; i++)
{
if(i == stt || i == enn)
{
cou ++;
for(j=0; j<=cap; j++)
{
dp[i][j+1] += dp[i-1][j];
dp[i][j+1] %= mo;
dp[i][j] += dp[i-1][j];
dp[i][j] %= mo;
}
continue;
}
for(j=0; j<=cap; j++)
{
// if(j > 0)
dp[i][j] += dp[i-1][j+1] * (j);
dp[i][j] %= mo;
if(j+1-cou >= 0)
dp[i][j+1] += dp[i-1][j] * (j+1-cou);
dp[i][j+1] %= mo;
}
}
printf("%lld\n",dp[n][1]);
return 0;
}
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... |