제출 #813959

#제출 시각아이디문제언어결과실행 시간메모리
813959kebineTents (JOI18_tents)C++17
100 / 100
111 ms70868 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 = 3e3 + 5; const int mod = 1e9 + 7; ll dp1[N][N], dp2[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int h, w; cin >> h >> w; dp1[0][w] = 1; for (int i = 0; i < h; i++) { for (int j = w; j >= 0; j--) { if (j >= 2) { dp1[i + 1][j - 2] += ((j * (j - 1) / 2) % mod) * dp1[i][j]; dp1[i + 1][j - 2] %= mod; } if (j >= 1) { dp1[i + 1][j - 1] += j * dp2[j] + 4 * j * dp1[i][j]; dp1[i + 1][j - 1] %= mod; } dp1[i + 1][j] += dp1[i][j]; dp1[i + 1][j] %= mod; dp2[j] += (i + 1) * dp1[i][j] - i * dp1[max(i - 1, 0)][j]; dp2[j] %= mod; } } ll ans = 0; for (int i = 0; i < w; i++) { ans += dp1[h][i]; ans %= mod; } cout << ans << "\n"; // for (int i = 0; i <= h; i++) { // for (int j = w; j >= 0; j--) cout << dp1[i][j] << " "; // cout << "\n"; // } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...