# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
643277 | 2022-09-21T16:02:56 Z | valerikk | Tents (JOI18_tents) | C++17 | 116 ms | 70720 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 468 KB | Output is correct |
4 | Correct | 1 ms | 1060 KB | Output is correct |
5 | Correct | 1 ms | 616 KB | Output is correct |
6 | Correct | 1 ms | 1316 KB | Output is correct |
7 | Correct | 1 ms | 724 KB | Output is correct |
8 | Correct | 1 ms | 1364 KB | Output is correct |
9 | Correct | 1 ms | 724 KB | Output is correct |
10 | Correct | 1 ms | 1748 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 2132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 468 KB | Output is correct |
4 | Correct | 1 ms | 1060 KB | Output is correct |
5 | Correct | 1 ms | 616 KB | Output is correct |
6 | Correct | 1 ms | 1316 KB | Output is correct |
7 | Correct | 1 ms | 724 KB | Output is correct |
8 | Correct | 1 ms | 1364 KB | Output is correct |
9 | Correct | 1 ms | 724 KB | Output is correct |
10 | Correct | 1 ms | 1748 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 2132 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 4 ms | 9556 KB | Output is correct |
15 | Correct | 78 ms | 55104 KB | Output is correct |
16 | Correct | 5 ms | 3924 KB | Output is correct |
17 | Correct | 18 ms | 12816 KB | Output is correct |
18 | Correct | 22 ms | 16988 KB | Output is correct |
19 | Correct | 86 ms | 62924 KB | Output is correct |
20 | Correct | 69 ms | 50764 KB | Output is correct |
21 | Correct | 50 ms | 33728 KB | Output is correct |
22 | Correct | 46 ms | 35404 KB | Output is correct |
23 | Correct | 29 ms | 26960 KB | Output is correct |
24 | Correct | 115 ms | 70720 KB | Output is correct |
25 | Correct | 88 ms | 61060 KB | Output is correct |
26 | Correct | 106 ms | 66540 KB | Output is correct |
27 | Correct | 116 ms | 68900 KB | Output is correct |