Submission #1122764

#TimeUsernameProblemLanguageResultExecution timeMemory
1122764SulATents (JOI18_tents)C++20
100 / 100
117 ms70928 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> //#pragma GCC target("popcnt") using namespace __gnu_pbds; using namespace std; using ordered_set = tree<int, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>; #define popcount __builtin_popcountll #define all(a) (a).begin(), (a).end() const int MOD = 1e9+7; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int h,w; cin >> h >> w; long long dp[h+1][w+1] = {}; for (int i = 0; i <= h; i++) dp[i][0] = 1; for (int j = 0; j <= w; j++) dp[0][j] = 1; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { dp[i][j] = (dp[i-1][j] + dp[i-1][j-1] * 4*j) % MOD; if (i >= 2) (dp[i][j] += dp[i-2][j-1] * (i-1) * j % MOD) %= MOD; if (j >= 2) (dp[i][j] += dp[i-1][j-2] * j * (j-1) / 2) %= MOD; } } cout << (MOD + dp[h][w] - 1) % MOD; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...