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 dp[3005][3005];
int sum[3005][3005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int h,w;cin>>h>>w;
dp[0][w]=1;
for(int i=0;i<=h;i++){
for(int j=0;j<=w;j++){
dp[i+1][j]+=dp[i][j];
if(j>0)dp[i+1][j-1]+=dp[i][j]*j*4;
if(j>1)dp[i+1][j-2]+=dp[i][j]*j*(j-1)/2;
dp[i+1][j]+=sum[i][j];
sum[i+1][j]+=sum[i][j];
if(j>0)sum[i+1][j-1]+=(sum[i][j]*j)+dp[i][j]*j;
//
sum[i+1][j]+=sum[i][j]-sum[i][j];//wrong
//
if(j>0)sum[i+1][j-1]+=sum[i][j]*3*j;
if(j>1)sum[i+1][j-2]+=sum[i][j]*j*(j-1)/2;
}
}
int ans=0;
for(int i=0;i<=w;i++){
ans+=dp[h][i];
}
cout<<ans-1<<"\n";
}
//ill finish later
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |