結果

問題 No.140 みんなで旅行
ユーザー ytftytft
提出日時 2021-03-15 22:07:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,043 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 168,064 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-25 01:21:26
合計ジャッジ時間 6,614 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    long long MOD=pow(10,9)+7;
    cin>>N;
    vector<vector<long long>> dp(N,vector<long long>(2*N+1));
    vector<vector<long long>> C(N,vector<long long>(N));
    for(long long i=0;i<N;i++){
        for(long long j=0;j<N;j++){
            if(i<j){
                C[i][j]=0;
            }else if(i==j || j==0){
                C[i][j]=1;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
            }
        }
    }
    for(long long i=0;i<N;i++){
        for(long long j=0;j<=2*N;j++){
            if(j==0){
                dp[i][j]=0;
            }else if(i==0){
                dp[i][j]=(j==1?1:0);
            }else{
                dp[i][j]=dp[i-1][j]*j*j;
                for(int k=0;k<i;k++){
                    dp[i][j]=(dp[i][j]+C[i][k]*(1<<k)*dp[i-k-1][j-1])%MOD;
                }
            }
        }
    }
    long long ans=0;
    for(long long j=0;j<=2*N;j++){
        ans=(ans+dp[N-1][j])%MOD;
    }
    cout<<ans<<endl;
}
0