Submission #84378

#TimeUsernameProblemLanguageResultExecution timeMemory
84378Alexa2001Tents (JOI18_tents)C++17
100 / 100
228 ms36056 KiB
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7, Nmax = 3003; typedef long long ll; int inm(int x, int y) { return (ll)x*y%Mod; } void add_to(int &x, int y) { x+=y; if(x>=Mod) x-=Mod; } int n, m, i, j, dp[Nmax][Nmax]; int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); cin >> n >> m; for(i=0; i<=n || i<=m; ++i) dp[0][i] = dp[i][0] = 1; for(i=1; i<=n; ++i) for(j=1; j<=m; ++j) { dp[i][j] = dp[i-1][j]; if(j>=2) add_to(dp[i][j], inm(dp[i-1][j-2], j*(j-1)/2)); if(i>=2) add_to(dp[i][j], inm(dp[i-2][j-1], (i-1) * j)); add_to(dp[i][j], inm(4 * j, dp[i-1][j-1])); } add_to(dp[n][m], Mod-1); cout << dp[n][m] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...