이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
const int mod=1e9+7;
int n;int m;
int dp[5010][5010];
int cn2(int x){
return ((x*(x-1))/2)%mod;
}
signed main(){
cin>>n>>m;
dp[0][m]=1;
for(int H=1;H<=n;H++){
for(int W=0;W<=m;W++){
dp[H][W]=dp[H-1][W];
dp[H][W]=(dp[H][W]+dp[H-1][W+1]*4*(W+1) )%mod;
dp[H][W]=(dp[H][W]+dp[H-1][W+2]*cn2(W+2))%mod;
if(H>=2){
dp[H][W]=(dp[H][W]+dp[H-2][W+1]*(W+1)%mod*(H-1))%mod;
}
}
}
int ans=0;
for(int i=0;i<=m-1;i++){
ans=(ans+dp[n][i])%mod;
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |