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<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define mid (low+high)/2
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 3004
#define INF 1e9+7
using namespace std;
ll n,m,mod=1e9+7;
ll dp[N][N];
ll solve(ll i,ll j)
{
if(i < 0 || j < 0)
return 0;
if(i==0||j==0)
return 1;
if(dp[i][j]!=-1)
return dp[i][j];
return dp[i][j] = ((solve(i-1,j-2)*(j*(j-1))/2)%mod + (solve(i-2,j-1)*(i-1)*j)%mod + (4*j*solve(i-1,j-1))%mod + (solve(i-1,j)))%mod;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
memset(dp,-1,sizeof dp);
cin >> n >> m;
cout << (solve(n,m)-1+mod)%mod << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |