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