# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1109772 |
2024-11-07T14:21:40 Z |
ttamx |
Tents (JOI18_tents) |
C++17 |
|
34 ms |
71024 KB |
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N=3005;
const int MOD=1e9+7;
int h,w;
ll dp[N][N];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> h >> w;
for(int i=0;i<=h;i++){
dp[i][0]=1;
}
for(int i=0;i<=w;i++){
dp[0][i]=1;
}
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
dp[i][j]+=dp[i-1][j];
dp[i][j]+=dp[i-1][j-1]*j*4;
if(i>=2){
dp[i][j]+=dp[i-2][j-1]*(i-1)*j;
}
if(j>=2){
dp[i][j]+=dp[i-1][j-2]*(1LL*j*(j-1)/2);
}
dp[i][j]%=MOD;
}
}
cout << (dp[h][w]-1+MOD)%MOD;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
2 ms |
6648 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
2 ms |
6480 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
4432 KB |
Output is correct |
10 |
Correct |
2 ms |
8528 KB |
Output is correct |
11 |
Correct |
1 ms |
2552 KB |
Output is correct |
12 |
Correct |
2 ms |
8528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
2 ms |
6648 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
2 ms |
6480 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
4432 KB |
Output is correct |
10 |
Correct |
2 ms |
8528 KB |
Output is correct |
11 |
Correct |
1 ms |
2552 KB |
Output is correct |
12 |
Correct |
2 ms |
8528 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
7 ms |
55888 KB |
Output is correct |
15 |
Correct |
23 ms |
66128 KB |
Output is correct |
16 |
Correct |
3 ms |
6736 KB |
Output is correct |
17 |
Correct |
6 ms |
16976 KB |
Output is correct |
18 |
Correct |
8 ms |
29436 KB |
Output is correct |
19 |
Correct |
26 ms |
70404 KB |
Output is correct |
20 |
Correct |
22 ms |
58104 KB |
Output is correct |
21 |
Correct |
15 ms |
39504 KB |
Output is correct |
22 |
Correct |
16 ms |
51792 KB |
Output is correct |
23 |
Correct |
14 ms |
70480 KB |
Output is correct |
24 |
Correct |
34 ms |
71024 KB |
Output is correct |
25 |
Correct |
24 ms |
62032 KB |
Output is correct |
26 |
Correct |
28 ms |
68176 KB |
Output is correct |
27 |
Correct |
31 ms |
70224 KB |
Output is correct |