Submission #706286

#TimeUsernameProblemLanguageResultExecution timeMemory
706286lukameladzeTents (JOI18_tents)C++14
100 / 100
121 ms70860 KiB
# include <bits/stdc++.h> #define f first #define s second #define pb push_back #define int long long using namespace std; const int N = 3005, mod = 1e9 + 7; int n, m, dp[N][N]; int C(int n, int k) { return n * (n - 1) / 2; } main() { cin>>n>>m; for (int i = 0; i <= max(n,m); i++) dp[0][i] = dp[i][0] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] += dp[i - 1][j]; if (j >= 2) dp[i][j] = (dp[i][j] + dp[i - 1][j - 2] * C(j, 2)) % mod; dp[i][j] = (dp[i][j] + (dp[i - 1][j - 1] * 4 * j) % mod) % mod; if (i >= 2) dp[i][j] += dp[i - 2][j - 1] * j * (i - 1) % mod; dp[i][j] %= mod; } } dp[n][m] = (dp[n][m] - 1 + mod) % mod; cout<<dp[n][m]<<"\n"; }

Compilation message (stderr)

tents.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...