이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll dp[4000][4000];
int main(){
int h,w;cin>>h>>w;
dp[0][w]=1;
rep(i,h)rep(j,w+1){
//0
(dp[i+1][j]+=dp[i][j])%=MOD;
//1
if(j)(dp[i+1][j-1]+=dp[i][j]*j*4)%=MOD;
//N-S
if(j&&i<h-1)(dp[i+2][j-1]+=dp[i][j]*j*(h-i-1))%=MOD;
//E-W
if(j>=2)(dp[i+1][j-2]+=dp[i][j]*(j*(j-1)/2))%=MOD;
}
ll ans=0;
rep(i,w+1)(ans+=dp[h][i])%=MOD;
cout<<(ans+MOD-1)%MOD<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |