Submission #1283708

#TimeUsernameProblemLanguageResultExecution timeMemory
1283708chikien2009Tents (JOI18_tents)C++20
100 / 100
72 ms70836 KiB
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int h, w; long long f[3001][3001]; long long a, b, res; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> h >> w; f[0][0] = 1; for (int i = 1; i <= 3e3; ++i) { f[i][0] = 1; } for (int i = 1; i <= h; ++i) { for (int j = 1; j <= w; ++j) { a = h - i + 1; b = w - j + 1; f[i][j] = (f[i - 1][j] + f[i - 1][j - 1] * 4 * b) % mod; if (1 < i) { (f[i][j] += f[i - 2][j - 1] * (i - 1) * b) %= mod; } if (1 < j) { b = w - j + 2; (f[i][j] += f[i - 1][j - 2] * b * (b - 1) / 2) %= mod; } } } for (int i = 1; i <= w; ++i) { (res += f[h][i]) %= mod; } cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...