제출 #555768

#제출 시각아이디문제언어결과실행 시간메모리
555768new_accZapina (COCI20_zapina)C++14
110 / 110
160 ms3684 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=400+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int t[N];
ll nw[N][N],dp[N][N][2];
void solve(){
    int n;
    cin>>n;
    nw[0][0]=1;
    for(int i=1;i<=n;i++){
        nw[i][0]=1;
        for(int j=1;j<=i;j++) (nw[i][j]=nw[i-1][j]+nw[i-1][j-1])%=mod;
    }
    dp[0][0][0]=1;
    for(int i=1;i<=n;i++){
        dp[i][0][0]=1;
        for(int j=1;j<=n;j++){
            for(int k=0;k<=j;k++){
                ll curr=nw[j][k];
                if(k==i){
                    (dp[i][j][1]+=dp[i-1][j-k][0]*curr+dp[i-1][j-k][1]*curr)%=mod;
                    continue;
                }
                (dp[i][j][1]+=dp[i-1][j-k][1]*curr)%=mod;
                (dp[i][j][0]+=dp[i-1][j-k][0]*curr)%=mod;
            }
        }
    }
    cout<<dp[n][n][1]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int tt=1;
    while(tt--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...