結果

問題 No.2711 Connecting Lights
ユーザー ThetaTheta
提出日時 2024-04-10 16:44:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 4,611 ms / 5,000 ms
コード長 948 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,628 KB
実行使用メモリ 153,848 KB
最終ジャッジ日時 2024-04-10 16:44:49
合計ジャッジ時間 40,501 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,224 KB
testcase_01 AC 34 ms
52,480 KB
testcase_02 AC 46 ms
64,000 KB
testcase_03 AC 32 ms
52,224 KB
testcase_04 AC 32 ms
52,004 KB
testcase_05 AC 98 ms
81,872 KB
testcase_06 AC 69 ms
76,644 KB
testcase_07 AC 70 ms
78,280 KB
testcase_08 AC 112 ms
80,088 KB
testcase_09 AC 2,683 ms
121,600 KB
testcase_10 AC 2,129 ms
112,512 KB
testcase_11 AC 3,855 ms
140,724 KB
testcase_12 AC 959 ms
105,140 KB
testcase_13 AC 1,196 ms
111,292 KB
testcase_14 AC 146 ms
82,640 KB
testcase_15 AC 684 ms
94,080 KB
testcase_16 AC 109 ms
82,160 KB
testcase_17 AC 117 ms
83,324 KB
testcase_18 AC 180 ms
85,376 KB
testcase_19 AC 3,035 ms
127,636 KB
testcase_20 AC 1,274 ms
113,076 KB
testcase_21 AC 113 ms
82,624 KB
testcase_22 AC 81 ms
77,696 KB
testcase_23 AC 88 ms
80,616 KB
testcase_24 AC 1,781 ms
105,152 KB
testcase_25 AC 2,097 ms
111,176 KB
testcase_26 AC 4,596 ms
153,680 KB
testcase_27 AC 4,561 ms
153,848 KB
testcase_28 AC 4,611 ms
153,776 KB
testcase_29 AC 4,546 ms
153,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, M, K = map(int, input().split())
    MOD = 998244353
    if M == 1:
        print(pow(2, N, MOD))
        return

    dp_table = [[[0 for _ in range(N + 1)]
                 for _ in range(2**N)] for _ in range(M)]
    for column in range(M):
        for c_bit in range(2**N):
            if column == 0:
                dp_table[column][c_bit][c_bit.bit_count()] += 1
                continue

            for prev_bit in range(2**N):
                for prev_ctr in range(N + 1):
                    dp_table[column][c_bit][min(prev_ctr, (c_bit & prev_bit).bit_count(
                    ))] += (dp_table[column - 1][prev_bit][prev_ctr])
                    dp_table[column][c_bit][min(
                        prev_ctr, (c_bit & prev_bit).bit_count())] %= MOD
    ans = 0
    for elm in dp_table[-1]:
        for v in elm[K:]:
            ans += v
            ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()
0