# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388623 | denkendoemeer | Tents (JOI18_tents) | C++14 | 255 ms | 31940 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 mod 1000000007
using namespace std;
#define ll long long
int dp[3005][3005];
ll calc(int a,int b)
{
if (a<=0 || b<=0)
return 1;
if (dp[a][b])
return dp[a][b];
ll ans=0;
ans+=calc(a-1,b);
ans+=(b*(a-1))*calc(a-2,b-1);
ans+=((b*(b-1))/2)*calc(a-1,b-2);
ans+=calc(a-1,b-1)*b*4;
ans=ans%mod;
dp[a][b]=ans;
return ans;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int n,m;
scanf("%d%d",&n,&m);
printf("%lld\n",calc(n,m)-1);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |