이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define left 2*i+1
#define righ 2*i+2
#define mid (l+r)/2
using namespace std;
const ll mod=1e9+7;
ll n,dp[400][400][2],ch[400][400];
ll solve(ll st,ll pr,ll ok){
if(st==n){
if(pr==n)return ok;
return 0;
}
ll &ans=dp[st][pr][ok];
if(ans+1)return ans;
ans=0;
for(ll i=0;i+pr<=n;i++){
if(st+1==i){
ans=(ans+solve(st+1,pr+i,1)*ch[n-pr][i]%mod)%mod;
}
else
ans=(ans+solve(st+1,pr+i,ok)*ch[n-pr][i]%mod)%mod;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
memset(dp,-1,sizeof dp);
for(ll i=0;i+25<400;i++){
ch[i][0]=1;
for(ll j=1;j<=i;j++){
ch[i][j]=(ch[i-1][j]+ch[i-1][j-1])%mod;
}
}
cout<<solve(0,0,0)<<endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |