이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <fstream>
using namespace std;
const long long mod=1000*1000*1000+7;
long long dp[3005][3005];
int h,w;
long long i,j;
int main()
{
// freopen("data.in","r",stdin);
cin>>h>>w;
for(i=0;i<=max(h,w);i++)
dp[i][0]=dp[0][i]=1;
for(i=1;i<=h;i++)
{
for(j=1;j<=w;j++)
{
dp[i][j]+=(1LL*dp[i-1][j])%mod;
if(j>=2)dp[i][j]+=(1LL*dp[i-1][j-2]*j*(j-1)/2)%mod;
if(i>=2)dp[i][j]+=(dp[i-2][j-1]*1LL*(i-1)*j)%mod;
dp[i][j]+=(dp[i-1][j-1]*4*j)%mod;
dp[i][j]%=mod;
}
}
cout<<(dp[h][w]-1+mod)%mod;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |