結果

問題 No.2711 Connecting Lights
ユーザー ynishi2015ynishi2015
提出日時 2024-03-31 14:35:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 799 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 92,516 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:35:34
合計ジャッジ時間 2,004 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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