Submission #1109771

#TimeUsernameProblemLanguageResultExecution timeMemory
1109771WarinchaiTents (JOI18_tents)C++14
100 / 100
88 ms70984 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int dp[3005][3005]; int md=1e9+7; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); int h,w;cin>>h>>w; for(int i=0;i<=h;i++)dp[i][0]=1; for(int i=0;i<=w;i++)dp[0][i]=1; for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ dp[i][j]=(dp[i][j]+dp[i-1][j-1]*j*4+dp[i-1][j])%md; if(j>1)dp[i][j]=(dp[i][j]+dp[i-1][j-2]*(j)*(j-1)/2)%md; if(i>1)dp[i][j]=(dp[i][j]+(i-1)*j*dp[i-2][j-1])%md; } } cout<<(dp[h][w]-1+md)%md<<"\n"; } //ill finish later
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...