結果

問題 No.1749 ラムドスウイルスの感染拡大
ユーザー horitaka1999horitaka1999
提出日時 2021-11-19 23:13:32
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 742 bytes
コンパイル時間 1,336 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 98,464 KB
最終ジャッジ日時 2023-08-30 10:23:19
合計ジャッジ時間 6,475 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,684 KB
testcase_01 AC 72 ms
71,288 KB
testcase_02 AC 78 ms
75,964 KB
testcase_03 AC 73 ms
71,120 KB
testcase_04 AC 147 ms
77,732 KB
testcase_05 AC 72 ms
71,284 KB
testcase_06 AC 70 ms
71,292 KB
testcase_07 AC 72 ms
71,296 KB
testcase_08 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,T = map(int,input().split())
MOD = 998244353
def mulmod(a,b,mod):
    return a*b%mod
def mat_mul_Pypy(A,B):
    return [[sum([mulmod(A[i][k],B[k][j],MOD) for k in range(len(B))])%MOD for j in range(len(B[0]))] for i in range(len(A))]

def mat_power_Pypy(A, N):#行列累乗
    P = [[1 if i==j else 0 for i in range(len(A[0]))] for j in range(len(A))]
    while N:
        if N & 1:
            P = mat_mul_Pypy(P, A)
        A = mat_mul_Pypy(A, A)
        N >>= 1
    return P
mat = [[0] * N for _ in range(N)]
for _ in range(M):
    s,t = map(int,input().split())
    mat[s][t] = 1
    mat[t][s] = 1
P = mat_power_Pypy(mat,T)
initial = [[0] * 1 for _ in range(N)]
initial[0][0] = 1
ans_mat = mat_mul_Pypy(P,initial)
print(ans_mat[0][0])
0