# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1034059 |
2024-07-25T09:17:54 Z |
vjudge1 |
Tents (JOI18_tents) |
C++17 |
|
132 ms |
70736 KB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m;
cin>>n>>m;
int dp[n+1][m+1];
memset(dp,0,sizeof(dp));
for(int j=0;j<=m;j++) dp[0][j]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=m;j++){
dp[i][j]=dp[i-1][j-1]*4*j%mod;
dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
if(j>1) dp[i][j]=(dp[i][j]+dp[i-1][j-2]*(j*(j-1)/2%mod)%mod)%mod;
if(i>1) dp[i][j]=(dp[i][j]+dp[i-2][j-1]*j%mod*(i-1)%mod)%mod;
}
}
cout<<(dp[n][m]-1+mod)%mod;
}
# |
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 |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
392 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
1116 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 |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
392 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
1116 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
90 ms |
44124 KB |
Output is correct |
16 |
Correct |
6 ms |
3264 KB |
Output is correct |
17 |
Correct |
18 ms |
10076 KB |
Output is correct |
18 |
Correct |
23 ms |
12380 KB |
Output is correct |
19 |
Correct |
97 ms |
51292 KB |
Output is correct |
20 |
Correct |
78 ms |
41228 KB |
Output is correct |
21 |
Correct |
53 ms |
27228 KB |
Output is correct |
22 |
Correct |
50 ms |
26908 KB |
Output is correct |
23 |
Correct |
28 ms |
14940 KB |
Output is correct |
24 |
Correct |
132 ms |
70736 KB |
Output is correct |
25 |
Correct |
101 ms |
52568 KB |
Output is correct |
26 |
Correct |
116 ms |
60252 KB |
Output is correct |
27 |
Correct |
127 ms |
68180 KB |
Output is correct |