結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー rlangevinrlangevin
提出日時 2023-02-07 12:32:19
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 709 bytes
コンパイル時間 820 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 844,532 KB
最終ジャッジ日時 2023-09-18 20:11:01
合計ジャッジ時間 4,589 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
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 #

def Matprod(A, B, mod):
    N = len(A)
    temp = [0] * (N * N)
    for i in range(N):
        for k in range(N):
            for j in range(N):
                temp[i*N+j] += A[i*N+k] * B[k*N+j]
                temp[i*N+j] %= mod
    return temp

def Matpow(A, M, mod):
    N = len(A)
    Mat = [[0] * N for i in range(N)]
    for i in range(N):
        Mat[i*N+i] = 1
         
    for i in range(64):
        if (M >> i) & 1:
            Mat = Matprod(Mat, A, mod)
        A = Matprod(A, A, mod)
    return Mat

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

G = Matpow(G, T, mod)
print(G[0])
0