# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
643277 | valerikk | Tents (JOI18_tents) | C++17 | 116 ms | 70720 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#define MOD 1000000007
#define MAX 3003
long long dp[MAX][MAX];
int main() {
int H, W;
scanf("%d%d", &H, &W);
dp[0][0] = 1;
for (int w = 1; w <= W; ++w) {
dp[0][w] = 1;
}
for (int h = 1; h <= H; ++h) {
dp[h][0] = 1;
}
for (int h = 1; h <= H; ++h) {
for (int w = 1; w <= W; ++w) {
dp[h][w] = (dp[h][w] + dp[h - 1][w]) % MOD;
if (w >= 2)
dp[h][w] = (dp[h][w] + w * 1LL * (w - 1) / 2 % MOD * dp[h - 1][w - 2]) % MOD;
dp[h][w] = (dp[h][w] + w * 4 * dp[h - 1][w - 1]) % MOD;
if (h >= 2)
dp[h][w] = (dp[h][w] + w * 1LL * (h - 1) * dp[h - 2][w - 1]) % MOD;
}
}
printf("%lld\n", (dp[H][W] - 1 + MOD) % MOD);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |