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>
#define int long long
using namespace std;
int dp[300][300][300];
int md=1e9+7;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int h,w;cin>>h>>w;
dp[0][w][0]=1;
for(int i=0;i<=h;i++){
for(int j=0;j<=w;j++){
for(int k=0;k<=w;k++){
dp[i+1][j-1][k]=(dp[i+1][j-1][k]+3*j*dp[i][j][k])%md;
dp[i+1][j-1][k+1]=(dp[i+1][j-1][k+1]+dp[i][j][k]*j)%md;
dp[i+1][j][k-1]=(dp[i+1][j][k-1]+dp[i][j][k]*k)%md;
dp[i+1][j-2][k]=(dp[i+1][j-2][k]+j*(j-1)/2*dp[i][j][k])%md;
dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%md;
}
}
}
int ans=0;
for(int i=0;i<=w;i++)for(int j=0;j<=w;j++)ans=(ans+dp[h][i][j])%md;
cout<<(ans-1)%md<<"\n";
}
//ill finish later
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |