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;
int h,w;
int memo[3001][3001];
long long dp(int a,int b){
if (a<=0 || b<=0) return 1;
if (memo[a][b]!=0) return memo[a][b];
long long ans=0;
ans+=dp(a-1,b);
ans+=4*b*dp(a-1,b-1);
ans+=((b*(b-1))/2)*dp(a-1,b-2);
ans+=(b*(a-1))*dp(a-2,b-1);
ans%=1000000007;
return memo[a][b]=ans;
}
int main() {
cin>>h>>w;
cout<<dp(h,w)-1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |