結果

問題 No.2711 Connecting Lights
ユーザー InTheBloomInTheBloom
提出日時 2024-03-31 14:38:36
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 300 ms / 5,000 ms
コード長 1,074 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 162,260 KB
実行使用メモリ 12,304 KB
最終ジャッジ日時 2024-03-31 14:38:44
合計ジャッジ時間 4,653 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 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 4 ms
6,676 KB
testcase_09 AC 176 ms
7,356 KB
testcase_10 AC 121 ms
7,356 KB
testcase_11 AC 213 ms
11,536 KB
testcase_12 AC 48 ms
7,464 KB
testcase_13 AC 53 ms
9,508 KB
testcase_14 AC 6 ms
6,676 KB
testcase_15 AC 33 ms
6,676 KB
testcase_16 AC 4 ms
6,676 KB
testcase_17 AC 6 ms
6,676 KB
testcase_18 AC 8 ms
6,676 KB
testcase_19 AC 173 ms
9,492 KB
testcase_20 AC 59 ms
9,508 KB
testcase_21 AC 5 ms
6,676 KB
testcase_22 AC 3 ms
6,676 KB
testcase_23 AC 5 ms
6,676 KB
testcase_24 AC 108 ms
7,356 KB
testcase_25 AC 136 ms
7,356 KB
testcase_26 AC 300 ms
12,304 KB
testcase_27 AC 263 ms
12,304 KB
testcase_28 AC 297 ms
12,304 KB
testcase_29 AC 254 ms
12,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    int N, M, K; readln.read(N, M, K);

    solve(N, M, K);
}

void solve (int N, int M, int K) {
    const long MOD = 998244353;
    auto dp = new long[][](M + 1, 1 << N);
    // dp[i][j] := 先頭i列が条件を満たし、最新列のランプがjである場合の数

    foreach (j; 0..(1 << N)) {
        dp[1][j] = 1;
    }

    foreach (i; 1..M) {
        foreach (j; 0..(1 << N)) {
            foreach (k; 0..(1 << N)) {
                int count = 0;
                foreach (l; 0..N) if (0 < (j & (1 << l)) && 0 < (k & (1 << l))) count++;
                if (K <= count) {
                    dp[i + 1][k] += dp[i][j];
                    dp[i + 1][k] %= MOD;
                }
            }
        }
    }

    long ans = 0;
    foreach (i; 0..(1 << N)) {
        ans += dp[M][i];
        ans %= MOD;
    }

    writeln(ans);
}

void read (T...) (string S, ref T args) {
    import std.conv : to;
    import std.array : split;
    auto buf = S.split;
    foreach (i, ref arg; args) {
        arg = buf[i].to!(typeof(arg));
    }
}
0