# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1010362 |
2024-06-29T01:06:07 Z |
snpmrnhlol |
Tents (JOI18_tents) |
C++17 |
|
98 ms |
35456 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3;
const int mod = 1e9 + 7;
int dp[N + 1][N + 1];
int main(){
int n,m;
cin>>n>>m;
dp[0][0] = 1;
for(int i = 0;i <= n;i++){
for(int j = 0;j <= m;j++){
if(i == 0 || j == 0){
dp[i][j] = 1;
continue;
}
dp[i][j] = dp[i - 1][j];
dp[i][j] = (dp[i][j] + 1ll*4*j*dp[i - 1][j - 1]%mod)%mod;
if(i >= 2)dp[i][j] = (dp[i][j] + 1ll*j*(i - 1)*dp[i - 2][j - 1]%mod)%mod;
if(j >= 2)dp[i][j] = (dp[i][j] + 1ll*j*(j - 1)/2*dp[i - 1][j - 2]%mod)%mod;
//cout<<dp[i][j]<<' ';
}
//cout<<'\n';
}
cout<<(dp[n][m] - 1 + mod)%mod<<' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
1116 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
0 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
1468 KB |
Output is correct |
9 |
Correct |
0 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
1116 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
0 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
1468 KB |
Output is correct |
9 |
Correct |
0 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
1884 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
9568 KB |
Output is correct |
15 |
Correct |
70 ms |
32852 KB |
Output is correct |
16 |
Correct |
5 ms |
2752 KB |
Output is correct |
17 |
Correct |
15 ms |
8028 KB |
Output is correct |
18 |
Correct |
18 ms |
11104 KB |
Output is correct |
19 |
Correct |
67 ms |
34364 KB |
Output is correct |
20 |
Correct |
61 ms |
29116 KB |
Output is correct |
21 |
Correct |
39 ms |
19800 KB |
Output is correct |
22 |
Correct |
36 ms |
22096 KB |
Output is correct |
23 |
Correct |
22 ms |
19808 KB |
Output is correct |
24 |
Correct |
98 ms |
35456 KB |
Output is correct |
25 |
Correct |
68 ms |
30616 KB |
Output is correct |
26 |
Correct |
83 ms |
33308 KB |
Output is correct |
27 |
Correct |
87 ms |
34548 KB |
Output is correct |