Submission #1003931

#TimeUsernameProblemLanguageResultExecution timeMemory
1003931AdamGSTents (JOI18_tents)C++17
100 / 100
65 ms70996 KiB
#include<bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const ll MOD=1e9+7; const int LIM=3e3+7; ll dp[LIM][LIM]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; rep(i, h+1) dp[i][0]=1; rep(i, w+1) dp[0][i]=1; for(int n=1; n<=h; ++n) for(int m=1; m<=w; ++m) { ll a=dp[n-1][m]; ll b=(dp[n-1][m-1]*4*m)%MOD; ll c=0; if(m>=2) c=(dp[n-1][m-2]*((m*(m-1)/2)%MOD))%MOD; ll d=0; if(n>=2) d=(dp[n-2][m-1]*((m*(n-1))%MOD))%MOD; dp[n][m]=(a+b+c+d)%MOD; } ll ans=(dp[h][w]-1+MOD)%MOD; cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...