Submission #44045

#TimeUsernameProblemLanguageResultExecution timeMemory
44045wxh010910Tents (JOI18_tents)C++17
100 / 100
89 ms35872 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back #define Debug(...) fprintf(stderr, __VA_ARGS__) typedef long long LL; typedef long double LD; typedef unsigned int uint; typedef pair <int, int> pii; typedef unsigned long long uLL; template <typename T> inline void Read(T &x) { char c = getchar(); bool f = false; for (x = 0; !isdigit(c); c = getchar()) { if (c == '-') { f = true; } } for (; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; } if (f) { x = -x; } } template <typename T> inline bool CheckMax(T &a, const T &b) { return a < b ? a = b, true : false; } template <typename T> inline bool CheckMin(T &a, const T &b) { return a > b ? a = b, true : false; } const int N = 3005; const int mod = 1e9 + 7; int n, m, ans, f[N][N]; int main() { #ifdef wxh010910 freopen("d.in", "r", stdin); #endif Read(n), Read(m), f[0][m] = 1; for (int i = 1; i <= n; ++i) { for (int j = 0; j <= m; ++j) { f[i][j] = (1LL * (j + 2) * (j + 1) / 2 * f[i - 1][j + 2] + 4LL * (j + 1) * f[i - 1][j + 1] + f[i - 1][j]) % mod; if (i >= 2) { f[i][j] = (1LL * (i - 1) * (j + 1) * f[i - 2][j + 1] + f[i][j]) % mod; } } } for (int i = 0; i <= m; ++i) { ans = (ans + f[n][i]) % mod; } printf("%d\n", (ans + mod - 1) % mod); #ifdef wxh010910 Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC); #endif return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...