#include<bits/stdc++.h>
#define int long long
using namespace std;
int dp[300][300][300];
int md=1e9+7;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int h,w;cin>>h>>w;
dp[0][w][0]=1;
for(int i=0;i<=h;i++){
for(int j=0;j<=w;j++){
for(int k=0;k<=w;k++){
dp[i+1][j-1][k]=(dp[i+1][j-1][k]+3*j*dp[i][j][k])%md;
dp[i+1][j-1][k+1]=(dp[i+1][j-1][k+1]+dp[i][j][k]*j)%md;
dp[i+1][j][k-1]=(dp[i+1][j][k-1]+dp[i][j][k]*k)%md;
dp[i+1][j-2][k]=(dp[i+1][j-2][k]+j*(j-1)/2*dp[i][j][k])%md;
dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%md;
}
}
}
int ans=0;
for(int i=0;i<=w;i++)for(int j=0;j<=w;j++)ans=(ans+dp[h][i][j])%md;
cout<<(ans-1)%md<<"\n";
}
//ill finish later
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
592 KB |
Output is correct |
2 |
Correct |
2 ms |
2848 KB |
Output is correct |
3 |
Correct |
2 ms |
848 KB |
Output is correct |
4 |
Correct |
4 ms |
3408 KB |
Output is correct |
5 |
Correct |
75 ms |
39496 KB |
Output is correct |
6 |
Correct |
54 ms |
51016 KB |
Output is correct |
7 |
Correct |
88 ms |
48968 KB |
Output is correct |
8 |
Correct |
36 ms |
37008 KB |
Output is correct |
9 |
Correct |
3 ms |
2640 KB |
Output is correct |
10 |
Correct |
131 ms |
98836 KB |
Output is correct |
11 |
Incorrect |
17 ms |
8696 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
592 KB |
Output is correct |
2 |
Correct |
2 ms |
2848 KB |
Output is correct |
3 |
Correct |
2 ms |
848 KB |
Output is correct |
4 |
Correct |
4 ms |
3408 KB |
Output is correct |
5 |
Correct |
75 ms |
39496 KB |
Output is correct |
6 |
Correct |
54 ms |
51016 KB |
Output is correct |
7 |
Correct |
88 ms |
48968 KB |
Output is correct |
8 |
Correct |
36 ms |
37008 KB |
Output is correct |
9 |
Correct |
3 ms |
2640 KB |
Output is correct |
10 |
Correct |
131 ms |
98836 KB |
Output is correct |
11 |
Incorrect |
17 ms |
8696 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |