# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
157537 |
2019-10-12T08:53:59 Z |
combi1k1 |
Tents (JOI18_tents) |
C++14 |
|
123 ms |
35548 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 1;
const int mod = 1e9 + 7;
void add(int &a,int b) {
a += b;
if (a >= mod)
a -= mod;
}
int mul(int a,int b) {
return 1ll * a * b % mod;
}
int f[N][N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int H; cin >> H;
int W; cin >> W;
for(int i = 0 ; i < N ; ++i)
f[i][0] = 1,
f[0][i] = 1;
for(int i = 1 ; i <= H ; ++i)
for(int j = 1 ; j <= W ; ++j) {
int &res = f[i][j];
add(res,f[i - 1][j]);
add(res,mul(f[i - 1][j - 1],4 * j));
if (i > 1) add(res,mul(f[i - 2][j - 1],j * (i - 1)));
if (j > 1) add(res,mul(f[i - 1][j - 2],j * (j - 1) / 2));
}
cout << (f[H][W] + mod - 1) % mod;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
12408 KB |
Output is correct |
2 |
Correct |
11 ms |
12408 KB |
Output is correct |
3 |
Correct |
11 ms |
12408 KB |
Output is correct |
4 |
Correct |
11 ms |
12408 KB |
Output is correct |
5 |
Correct |
11 ms |
12536 KB |
Output is correct |
6 |
Correct |
12 ms |
12536 KB |
Output is correct |
7 |
Correct |
12 ms |
12536 KB |
Output is correct |
8 |
Correct |
12 ms |
12408 KB |
Output is correct |
9 |
Correct |
11 ms |
12412 KB |
Output is correct |
10 |
Correct |
12 ms |
12536 KB |
Output is correct |
11 |
Correct |
11 ms |
12408 KB |
Output is correct |
12 |
Correct |
13 ms |
12764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
12408 KB |
Output is correct |
2 |
Correct |
11 ms |
12408 KB |
Output is correct |
3 |
Correct |
11 ms |
12408 KB |
Output is correct |
4 |
Correct |
11 ms |
12408 KB |
Output is correct |
5 |
Correct |
11 ms |
12536 KB |
Output is correct |
6 |
Correct |
12 ms |
12536 KB |
Output is correct |
7 |
Correct |
12 ms |
12536 KB |
Output is correct |
8 |
Correct |
12 ms |
12408 KB |
Output is correct |
9 |
Correct |
11 ms |
12412 KB |
Output is correct |
10 |
Correct |
12 ms |
12536 KB |
Output is correct |
11 |
Correct |
11 ms |
12408 KB |
Output is correct |
12 |
Correct |
13 ms |
12764 KB |
Output is correct |
13 |
Correct |
11 ms |
12408 KB |
Output is correct |
14 |
Correct |
11 ms |
12408 KB |
Output is correct |
15 |
Correct |
89 ms |
33736 KB |
Output is correct |
16 |
Correct |
16 ms |
13816 KB |
Output is correct |
17 |
Correct |
29 ms |
17272 KB |
Output is correct |
18 |
Correct |
34 ms |
18396 KB |
Output is correct |
19 |
Correct |
99 ms |
34940 KB |
Output is correct |
20 |
Correct |
83 ms |
31364 KB |
Output is correct |
21 |
Correct |
59 ms |
25180 KB |
Output is correct |
22 |
Correct |
59 ms |
25604 KB |
Output is correct |
23 |
Correct |
38 ms |
19736 KB |
Output is correct |
24 |
Correct |
123 ms |
35548 KB |
Output is correct |
25 |
Correct |
97 ms |
32376 KB |
Output is correct |
26 |
Correct |
109 ms |
34168 KB |
Output is correct |
27 |
Correct |
119 ms |
35064 KB |
Output is correct |