結果

問題 No.2711 Connecting Lights
ユーザー rin204rin204
提出日時 2024-04-07 14:27:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 869 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 64,340 KB
最終ジャッジ日時 2024-04-07 14:27:44
合計ジャッジ時間 2,772 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 43 ms
59,848 KB
testcase_02 AC 47 ms
61,960 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 48 ms
61,996 KB
testcase_07 AC 38 ms
53,460 KB
testcase_08 AC 45 ms
61,996 KB
testcase_09 AC 54 ms
64,040 KB
testcase_10 AC 53 ms
64,044 KB
testcase_11 AC 53 ms
64,040 KB
testcase_12 AC 50 ms
64,072 KB
testcase_13 AC 51 ms
64,076 KB
testcase_14 AC 45 ms
61,996 KB
testcase_15 AC 50 ms
64,084 KB
testcase_16 AC 38 ms
53,460 KB
testcase_17 AC 38 ms
53,460 KB
testcase_18 AC 46 ms
61,996 KB
testcase_19 AC 54 ms
64,040 KB
testcase_20 AC 52 ms
64,340 KB
testcase_21 AC 37 ms
53,460 KB
testcase_22 AC 37 ms
53,460 KB
testcase_23 AC 37 ms
53,460 KB
testcase_24 AC 53 ms
64,040 KB
testcase_25 AC 55 ms
64,044 KB
testcase_26 AC 54 ms
64,032 KB
testcase_27 AC 53 ms
64,032 KB
testcase_28 AC 53 ms
64,032 KB
testcase_29 AC 53 ms
64,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353


def mat_exp_global_mod(A, B, n):
    le = len(A)
    while n > 0:
        if n & 1:
            C = [0] * le
            for i in range(le):
                for j in range(le):
                    C[i] += A[i][j] * B[j]
                    C[i] %= MOD
            B = C
        C = [[0] * le for _ in range(le)]
        for i in range(le):
            for k in range(le):
                for j in range(le):
                    C[i][j] += A[i][k] * A[k][j]
                    C[i][j] %= MOD
        A = C
        n >>= 1

    return B


n, m, k = map(int, input().split())
x = 1 << n
if m == 1:
    print(x)
    exit()
A = [[0] * x for _ in range(x)]

for bit1 in range(x):
    for bit2 in range(x):
        if bin(bit1 & bit2).count("1") >= k:
            A[bit1][bit2] = 1

B = [0] * x
B[-1] = 1
C = mat_exp_global_mod(A, B, m)
print(sum(C) % MOD)
0