Submission #1091696

#TimeUsernameProblemLanguageResultExecution timeMemory
10916964QT0RTents (JOI18_tents)C++17
48 / 100
83 ms55176 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll mod=1e9+7; ll mult(ll a, ll b){ return (a*b)%mod; } ll chose(ll x){ return ((x*(x-1))/2)%mod; } ll dp[3003][3003]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n,m; cin >> n >> m; dp[0][0]=1; for (ll i = 1; i<=n; i++)dp[i][0]=1; for (ll i = 1; i<=m; i++)dp[0][i]=1; for (ll i = 1; i<=n; i++){ for (ll j = 1; j<=m; j++){ dp[i][j]=dp[i-1][j]; dp[i][j]+=mult(4*j,dp[i-1][j-1]); if (j>=2)dp[i][j]+=mult(chose(j),dp[i-1][j-2]); if (i>=2 && j>=1)dp[i][j]+=mult(mult(i-1,j),dp[i-2][j-1]); } } cout << (dp[n][m]+mod-1)%mod << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...