# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
999660 |
2024-06-16T03:05:30 Z |
overwatch9 |
Tents (JOI18_tents) |
C++17 |
|
190 ms |
69712 KB |
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int maxn = 3000 + 1;
ll dp[maxn][maxn];
bool ready[maxn][maxn];
ll sum(ll x) {
return ((x * (x-1)) / 2) % mod;
}
ll solve(ll h, ll w) {
if (h < 0 || w < 0)
return 0;
if (h == 0 || w == 0)
return 1;
if (ready[h][w])
return dp[h][w];
ll ans = 0;
// place nothing
ans = solve(h-1, w);
// place 1
ans += (solve(h-1, w-1) * w * 4) % mod;
ans %= mod;
// place 2 in same row
ans += (solve(h-1, w-2) * sum(w)) % mod;
ans %= mod;
// place 2 in same column
ans += (solve(h-2, w-1) * (h-1) * w) % mod;
ans %= mod;
ready[h][w] = true;
dp[h][w] = ans;
return ans;
}
int main() {
int h, w;
cin >> h >> w;
cout << (solve(h, w) - 1 + mod) % mod << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
7004 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
7260 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
1 ms |
9308 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
2 ms |
9308 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
3 ms |
9564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
7004 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
7260 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
1 ms |
9308 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
2 ms |
9308 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
3 ms |
9564 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
8 ms |
52316 KB |
Output is correct |
15 |
Correct |
133 ms |
63704 KB |
Output is correct |
16 |
Correct |
3 ms |
7256 KB |
Output is correct |
17 |
Correct |
15 ms |
20944 KB |
Output is correct |
18 |
Correct |
31 ms |
32628 KB |
Output is correct |
19 |
Correct |
159 ms |
66588 KB |
Output is correct |
20 |
Correct |
111 ms |
59492 KB |
Output is correct |
21 |
Correct |
70 ms |
46416 KB |
Output is correct |
22 |
Correct |
79 ms |
58248 KB |
Output is correct |
23 |
Correct |
57 ms |
65880 KB |
Output is correct |
24 |
Correct |
190 ms |
69712 KB |
Output is correct |
25 |
Correct |
141 ms |
61560 KB |
Output is correct |
26 |
Correct |
182 ms |
64784 KB |
Output is correct |
27 |
Correct |
189 ms |
66896 KB |
Output is correct |