結果

問題 No.2711 Connecting Lights
ユーザー inkyamaninkyaman
提出日時 2024-04-07 00:28:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 322 ms / 5,000 ms
コード長 1,284 bytes
コンパイル時間 1,262 ms
コンパイル使用メモリ 121,628 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-07 00:28:12
合計ジャッジ時間 4,429 ms
ジャッジサーバーID
(参考情報)
judge14 / 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 4 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 AC 185 ms
6,784 KB
testcase_10 AC 58 ms
6,676 KB
testcase_11 AC 107 ms
8,192 KB
testcase_12 AC 37 ms
6,676 KB
testcase_13 AC 31 ms
6,676 KB
testcase_14 AC 4 ms
6,676 KB
testcase_15 AC 36 ms
6,676 KB
testcase_16 AC 5 ms
6,676 KB
testcase_17 AC 6 ms
6,676 KB
testcase_18 AC 7 ms
6,676 KB
testcase_19 AC 82 ms
7,184 KB
testcase_20 AC 45 ms
6,676 KB
testcase_21 AC 5 ms
6,676 KB
testcase_22 AC 3 ms
6,676 KB
testcase_23 AC 4 ms
6,676 KB
testcase_24 AC 84 ms
6,676 KB
testcase_25 AC 145 ms
6,676 KB
testcase_26 AC 317 ms
9,088 KB
testcase_27 AC 151 ms
9,088 KB
testcase_28 AC 322 ms
9,088 KB
testcase_29 AC 122 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;

int N,M,K;
ll mod = 998244353;

int main() {

    cin >> N >> M >> K;
    vector dp(M, vector(1<<N, 0LL));
    for(int i = 0; i < 1<<N; ++i) dp[0][i] = 1;

    for(int i = 0; i < M-1; ++i) {
        for(int j = 0; j < 1<<N; ++j) {
            for(int k = 0; k < 1<<N; ++k) {
                int cnt = 0;
                for(int t = 0; t < N; ++t) {
                    if(((j>>t)&1) && ((k>>t)&1)) cnt++;
                }
                if(cnt >= K) {
                    dp[i+1][k] += dp[i][j];
                    dp[i+1][k] %= mod;
                }
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < 1<<N; ++i) {
        ans += dp[M-1][i];
        ans %= mod;
    }

    cout << ans << endl;

    // for(int i = 0; i < M; ++i) {
    //     for(int j = 0; j < 1<<N; ++j) {
    //         cout << "dp[" << i << "][" << j << "]:" << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

}

0