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