# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68617 | TadijaSebez | Tents (JOI18_tents) | C++11 | 218 ms | 36004 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>
#define ll long long
const int N=3005;
const int mod=1e9+7;
int dp[N][N];
int main()
{
int n,m,i,j;
scanf("%i %i",&n,&m);
for(i=0;i<=n;i++)
{
for(j=0;j<=m;j++)
{
if(i==0 || j==0){ dp[i][j]=1;continue;}
dp[i][j]=dp[i-1][j]+(ll)dp[i-1][j-1]*j%mod*4%mod;
dp[i][j]%=mod;
if(i>1) dp[i][j]+=(ll)dp[i-2][j-1]*j%mod*(i-1)%mod;
dp[i][j]%=mod;
if(j>1) dp[i][j]+=(ll)dp[i-1][j-2]*((ll)j*(j-1)/2%mod)%mod;
dp[i][j]%=mod;
}
}
printf("%i\n",(dp[n][m]+mod-1)%mod);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |