結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー AEnAEn
提出日時 2022-06-24 01:00:01
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 732 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 102,528 KB
最終ジャッジ日時 2024-04-25 08:57:53
合計ジャッジ時間 7,993 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
57,728 KB
testcase_01 AC 40 ms
52,096 KB
testcase_02 AC 40 ms
57,728 KB
testcase_03 AC 44 ms
59,392 KB
testcase_04 AC 156 ms
76,672 KB
testcase_05 AC 36 ms
52,224 KB
testcase_06 AC 37 ms
52,096 KB
testcase_07 AC 35 ms
52,224 KB
testcase_08 AC 502 ms
78,976 KB
testcase_09 AC 465 ms
78,592 KB
testcase_10 AC 502 ms
78,848 KB
testcase_11 AC 523 ms
79,360 KB
testcase_12 AC 610 ms
79,744 KB
testcase_13 AC 661 ms
80,128 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, T = map(int, input().split())
A = [[0]*N for _ in range(N)]
for i in range(M):
    s, t = map(int, input().split())
    A[s][t] = 1
    A[t][s] = 1

def mat_mul(a, b, mod=998244353) :
    I, J, K = len(a), len(b[0]), len(b)
    c = [[0] * J for _ in range(I)]
    for i in range(I) :
        for j in range(J) :
            for k in range(K) :
                c[i][j] += a[i][k] * b[k][j]
            c[i][j] %= mod
    return c

def mat_pow(x, n, mod=998244353):
    y = [[0] * len(x) for _ in range(len(x))]
    for i in range(len(x)):
        y[i][i] = 1
    while n > 0:
        if n & 1:
            y = mat_mul(x, y, mod)
        x = mat_mul(x, x, mod)
        n >>= 1
    return y

res = mat_pow(A, T)
print(res[0][0])
0