# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
817127 |
2023-08-09T09:42:22 Z |
gun_gan |
Tents (JOI18_tents) |
C++17 |
|
169 ms |
70832 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 3005, mod = 1e9 + 7, inv = 5e8 + 4;
int H, W;
ll dp[MX][MX];
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> H >> W;
dp[0][W] = 1;
for(int i = 0; i < H; i++) {
for(int a = 0; a <= W; a++) {
dp[i + 1][a] += dp[i][a];
dp[i + 1][a] %= mod;
if(a - 1 >= 0) {
dp[i + 1][a - 1] += 1LL * dp[i][a] * a * 4 % mod;
dp[i + 1][a - 1] %= mod;
}
if(a - 2 >= 0) {
dp[i + 1][a - 2] += 1LL * dp[i][a] * a % mod * (a - 1) % mod * inv % mod;
dp[i + 1][a - 2] %= mod;
}
if(i + 2 <= H && a - 1 >= 0) {
dp[i + 2][a - 1] += 1LL * dp[i][a] * (H - i - 1) % mod * a % mod;
dp[i + 2][a - 1] %= mod;
}
}
}
ll ans = 0;
for(int a = 0; a < W; a++) {
ans += dp[H][a];
ans %= mod;
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
1108 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 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 |
2 ms |
1736 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
3 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
1108 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 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 |
2 ms |
1736 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
3 ms |
2132 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
9684 KB |
Output is correct |
15 |
Correct |
110 ms |
55116 KB |
Output is correct |
16 |
Correct |
8 ms |
4048 KB |
Output is correct |
17 |
Correct |
25 ms |
12776 KB |
Output is correct |
18 |
Correct |
33 ms |
17004 KB |
Output is correct |
19 |
Correct |
134 ms |
62992 KB |
Output is correct |
20 |
Correct |
104 ms |
50808 KB |
Output is correct |
21 |
Correct |
69 ms |
33684 KB |
Output is correct |
22 |
Correct |
71 ms |
35472 KB |
Output is correct |
23 |
Correct |
43 ms |
26956 KB |
Output is correct |
24 |
Correct |
169 ms |
70832 KB |
Output is correct |
25 |
Correct |
130 ms |
61132 KB |
Output is correct |
26 |
Correct |
147 ms |
66576 KB |
Output is correct |
27 |
Correct |
162 ms |
68992 KB |
Output is correct |