이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define for0(i,n) for(int i=0;i<=(int)n;i++)
#define forn(i,n) for(int i=n;i>=1;i--)
#define fo(i,x,y) for(int i=x;i<=(int)y;i++)
#define fr(i,x,y) for(int i=x;i>=(int)y;i--)
#define pb push_back
#define mp make_pair
#define LL long long
const LL Mod=1000*1000*1000+7;
LL dp[3002][3002];
int main()
{
int w,h;
cin>>w>>h;
dp[0][0]=1;
for1(i,max(w,h))
{
dp[i][0]=1;
dp[0][i]=1;
}
for1(i,w)
for1(j,h)
{
LL num2=(j*(j-1))/2;
dp[i][j]=(dp[i-1][j])%Mod;
if(j>=2)
dp[i][j]=(dp[i][j]+((LL)num2*(LL)dp[i-1][j-2])%Mod)%Mod;
dp[i][j]=(dp[i][j]+((LL)(4*j)*(LL)dp[i-1][j-1])%Mod)%Mod;
if(i>=2)
dp[i][j]=(dp[i][j]+((LL)(j*(i-1))*(LL)(dp[i-2][j-1]))%Mod)%Mod;
}
cout<<(dp[w][h]-1+Mod)%Mod<<endl;
return 0;
}
/*
4 3
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |