結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー AEnAEn
提出日時 2022-06-24 01:17:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,121 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-04-25 09:13:43
合計ジャッジ時間 13,902 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,840 KB
testcase_01 AC 38 ms
52,480 KB
testcase_02 AC 44 ms
58,496 KB
testcase_03 AC 44 ms
59,776 KB
testcase_04 AC 85 ms
68,608 KB
testcase_05 AC 37 ms
52,352 KB
testcase_06 AC 40 ms
52,352 KB
testcase_07 AC 40 ms
52,096 KB
testcase_08 AC 238 ms
76,160 KB
testcase_09 AC 240 ms
76,160 KB
testcase_10 AC 240 ms
75,904 KB
testcase_11 AC 200 ms
76,160 KB
testcase_12 AC 263 ms
76,032 KB
testcase_13 AC 243 ms
76,160 KB
testcase_14 AC 1,026 ms
76,672 KB
testcase_15 AC 1,058 ms
77,056 KB
testcase_16 AC 1,098 ms
76,928 KB
testcase_17 AC 1,092 ms
76,416 KB
testcase_18 AC 1,121 ms
76,672 KB
testcase_19 AC 1,085 ms
76,544 KB
testcase_20 AC 717 ms
76,288 KB
testcase_21 AC 843 ms
76,288 KB
testcase_22 AC 206 ms
76,160 KB
testcase_23 AC 984 ms
76,288 KB
testcase_24 AC 169 ms
76,032 KB
testcase_25 AC 308 ms
75,648 KB
testcase_26 AC 145 ms
75,648 KB
testcase_27 AC 55 ms
64,000 KB
testcase_28 AC 67 ms
69,504 KB
testcase_29 AC 53 ms
63,616 KB
testcase_30 AC 200 ms
75,904 KB
testcase_31 AC 199 ms
76,160 KB
testcase_32 AC 197 ms
76,160 KB
testcase_33 AC 191 ms
75,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def mat_mul(a, b) :
    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):
    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)
        x = mat_mul(x, x)
        n >>= 1
    return y

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