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 mod = 1000000007, vis[3001][3001], dp[3001][3001];
long long f(long long i, long long j)
{
if(i == 0 || j == 0) return 1;
if(i < 0 || j < 0) return 0;
if(vis[i][j]) return dp[i][j];
vis[i][j] = true;
dp[i][j] = ((f(i-1, j)+4*j*f(i-1, j-1))%mod+(f(i-1, j-2)*j*(j-1)/2)%mod+(f(i-2, j-1)*j*(i-1))%mod)%mod;
return dp[i][j];
}
int main()
{
long long n, m;
cin>>n>>m;
cout<<f(n, m)-1;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |