結果

問題 No.2711 Connecting Lights
ユーザー Yoichiro NishimuraYoichiro Nishimura
提出日時 2024-10-01 14:43:45
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 799 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 118,704 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-01 14:43:49
合計ジャッジ時間 3,369 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int popcount(int x){
    int c = 0;
    while(x){
        x &= x - 1;
        ++c;
    }
    return c;
}

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    vector<int> dp(1 << N, 1);
    int NN = 1 << N;
    int mod = 998244353;
    for(int i = 0; i < M-1; i++){
        vector<int> dpn(1 << N, 0);
        for(int b = 0; b < NN; b++){
            for(int c = 0; c < NN; c++){
                if(popcount(c & b) >= K){
                    dpn[c] += dp[b];
                }
                dpn[c] %= mod;
            }
        }
        dp = dpn;
    }
    int sum = 0;
    for(int i = 0; i < NN; i++){
        sum += dp[i];
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}
0