Submission #236943

#TimeUsernameProblemLanguageResultExecution timeMemory
236943aggu_01000101Tents (JOI18_tents)C++14
100 / 100
311 ms70776 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1000000007; signed main(){ int h, w; cin>>h>>w; int dp[h+1][w+1]; dp[1][1] = 5; 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 = 2;i<=h;i++){ dp[i][1] = dp[i-1][1] + (i-1) + 4; } for(int j = 2;j<=w;j++){ for(int i = 1;i<=h;i++){ dp[i][j] = dp[i][j-1]; dp[i][j]%=MOD; dp[i][j] += (((i*(j-1))%MOD)*dp[i-1][j-2])%MOD; dp[i][j]%=MOD; dp[i][j] += (4*i*dp[i-1][j-1])%MOD; dp[i][j]%=MOD; if(i>1) dp[i][j] += ((((i*(i-1))/2)%MOD) * (dp[i-2][j-1]))%MOD; dp[i][j]%=MOD; } } int ans = (dp[h][w] - 1 + MOD)%MOD; cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...