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 bruh=1e9+7;
bool d[3001][3001];
long long mem[3001][3001];
long long dp(long long n,long long m){
if(n<0||m<0)return 0;
if(n==0||m==0)return 1;
if(d[n][m])return mem[n][m];
d[n][m]=1;
return mem[n][m]=(((dp(n-1,m)%bruh+(4*m*dp(n-1,m -1))%bruh)%bruh+(dp(n-1,m-2)*m*(m-1)/2)%bruh)%bruh+(dp(n-2,m-1)*m*(n-1))%bruh)%bruh;
}
int main(){
ios_base::sync_with_stdio (0);
cin.tie(0);
cout.tie(0);
long long n,m;
cin>>n>>m;
cout<<dp(n,m)-1 ;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |