結果

問題 No.2711 Connecting Lights
ユーザー うえこうえこ
提出日時 2024-03-31 14:30:29
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 1,244 bytes
コンパイル時間 2,861 ms
コンパイル使用メモリ 251,568 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:30:33
合計ジャッジ時間 3,909 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 14 ms
6,676 KB
testcase_10 AC 4 ms
6,676 KB
testcase_11 AC 8 ms
6,676 KB
testcase_12 AC 8 ms
6,676 KB
testcase_13 AC 7 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 7 ms
6,676 KB
testcase_16 AC 4 ms
6,676 KB
testcase_17 AC 4 ms
6,676 KB
testcase_18 AC 4 ms
6,676 KB
testcase_19 AC 4 ms
6,676 KB
testcase_20 AC 10 ms
6,676 KB
testcase_21 AC 4 ms
6,676 KB
testcase_22 AC 3 ms
6,676 KB
testcase_23 AC 4 ms
6,676 KB
testcase_24 AC 8 ms
6,676 KB
testcase_25 AC 12 ms
6,676 KB
testcase_26 AC 22 ms
6,676 KB
testcase_27 AC 13 ms
6,676 KB
testcase_28 AC 22 ms
6,676 KB
testcase_29 AC 6 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ll=long long;
const long long INF=1LL<<60;
ll comb(ll a,ll b){
    ll val=1;
    for(int i=0;i<b;++i){
        val*=a;val/=(i+1);
        --a;
    }
    return val;
}
int main(){
    ll n,m,k;
    std::cin >> n >> m >> k;
    std::vector<std::vector<ll>>dp(m,std::vector<ll>(n+1));
    ll mod=998244353;
    for(int bit=0;bit<(1LL<<n);++bit){
        int cnt=0;
        for(int i=0;i<n;++i){
            if(bit&(1LL<<i))++cnt;
        }
        dp[0][cnt]++;
    }
    for(int i=0;i<m-1;++i){
        for(int j=0;j<=n;++j){
            for(int common=k;common<=j;++common){//jの中から共通のcommonこを選ぶのでchoose j, common
                ll add=comb(j,common);add%=mod;
                add*=dp[i][j];add%=mod;
                int other=n-j;
                for(int bit=0;bit<(1LL<<other);++bit){
                    int cnt=0;
                    for(int b=0;b<n;++b){
                        if(bit&(1LL<<b))++cnt;
                    }
                    int tot=cnt+common;
                    dp[i+1][tot]+=add;dp[i+1][tot]%=mod;
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=n;++i){
        ans+=dp.back()[i];ans%=mod;
    }
    std::cout << ans << '\n';
}
0