# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
558788 | hibiki | Kangaroo (CEOI16_kangaroo) | C++11 | 51 ms | 32016 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;
#define mod 1000000007
int n,s,t;
long dp[2005][2005];
long solve(int nw,long comp)
{
if(nw == 0) return 0;
long &val = dp[nw][comp];
if(val != -1) return val;
if(nw == 1) return val = (comp == 1)? 1 : 0;
if(nw == s || nw == t)
return val = (solve(nw - 1, comp - 1) + solve(nw - 1, comp)) % mod;
long del = 0;
if(nw > s) del++;
if(nw > t) del++;
return val = ( comp * solve(nw - 1, comp + 1) + (comp - del) * solve(nw - 1, comp - 1) ) % mod;
}
int main()
{
memset(dp, -1, sizeof(dp));
scanf("%d %d %d",&n,&s,&t);
printf("%ld\n",solve(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... |