Submission #813808

#TimeUsernameProblemLanguageResultExecution timeMemory
813808andecaandeciTents (JOI18_tents)C++17
48 / 100
295 ms217096 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define ull unsigned long long #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second const int N = 3e2 + 5; const int mod = 1e9 + 7; ll dp[N][N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int h, w; cin >> h >> w; dp[0][w][0] = 1; for (int i = 0; i < h; i++) { for (int j = w; j >= 0; j--) { for (int k = h; k >= 0; k--) { if (j >= 2) { dp[i + 1][j - 2][k] += j * (j - 1) / 2 * dp[i][j][k]; dp[i + 1][j - 2][k] %= mod; } if (j >= 1) { dp[i + 1][j - 1][k] += 4 * j * dp[i][j][k]; dp[i + 1][j - 1][k] %= mod; if (k >= 1) { dp[i + 1][j - 1][k - 1] += ((j * k) % mod) * dp[i][j][k]; dp[i + 1][j - 1][k - 1] %= mod; } } dp[i + 1][j][k + 1] += dp[i][j][k]; dp[i + 1][j][k + 1] %= mod; } } } ll ans = 0; for (int i = 0; i < w; i++) { for (int j = 0; j <= h; j++) { ans += dp[h][i][j]; ans %= mod; } } cout << ans << "\n"; // for (int i = 0; i <= h; i++) { // for (int j = 0; j <= w; j++) { // cout << i << " " << j << "gvawp\n"; // for (int k = 0; k <= w; k++) cout << dp[i][j][k] << " "; // cout << "\n"; // } // } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...