이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
typedef long long ll;
const int MX=3010, MOD=1e9+7;
int h, w, D[MX][MX];
int d(int x, int y){
int &res=D[x][y];
if(res>=0) return res;
res=d(x-1,y);
res=(res+4LL*d(x-1,y-1)*y)%MOD;
if(y>=2) res=(res+1LL*d(x-1,y-2)*(y*(y-1)/2))%MOD;
if(x>=2) res=(res+1LL*d(x-2,y-1)*y*(x-1))%MOD;
return res;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>h>>w;
for(int i=1; i<=h; i++) for(int j=1; j<=w; j++) D[i][j]=-1;
for(int i=0; i<=h; i++) D[i][0]=1;
for(int j=1; j<=w; j++) D[0][j]=1;
cout<<(d(h,w)+MOD-1)%MOD<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |