Submission #555502

#TimeUsernameProblemLanguageResultExecution timeMemory
555502wenqiTents (JOI18_tents)C++17
100 / 100
291 ms41700 KiB
// trans rights #include <bits/extc++.h> using namespace std; using ll = long long; using ull = unsigned long long; constexpr int mod = 1000000007; int W, H; int cache[3069][3069]; bool done[3069][3069]; int dp(int i, int j) { if (i <= 0 or j <= 0) return 1; bool &d = done[i][j]; int &ans = cache[i][j]; if (d) return ans; ans = (4ll * j * dp(i - 1, j - 1) + dp(i - 1, j)) % mod; ll B = ((ll) j * (j - 1)) / 2; if (i >= 2) ans = (ans + (ll) (i - 1) * j * dp(i - 2, j - 1)) % mod; if (j >= 2) ans = (ans + B * dp(i - 1, j - 2)) % mod; d = true; return ans; } int main(int argc, const char *argv[]) { ios::sync_with_stdio(false); cin.tie(0); cin >> W >> H; cout << (dp(W, H) - 1 + mod) % mod; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...