結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-24 09:01:29
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 817 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 78,248 KB
最終ジャッジ日時 2023-09-08 15:05:50
合計ジャッジ時間 27,184 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,540 KB
testcase_01 AC 72 ms
71,596 KB
testcase_02 AC 76 ms
75,904 KB
testcase_03 AC 80 ms
76,508 KB
testcase_04 AC 129 ms
76,480 KB
testcase_05 AC 71 ms
71,468 KB
testcase_06 AC 72 ms
71,384 KB
testcase_07 AC 71 ms
71,568 KB
testcase_08 AC 451 ms
77,452 KB
testcase_09 AC 453 ms
77,260 KB
testcase_10 AC 453 ms
77,428 KB
testcase_11 AC 364 ms
77,376 KB
testcase_12 AC 479 ms
77,336 KB
testcase_13 AC 457 ms
77,292 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,512 ms
77,608 KB
testcase_21 AC 1,756 ms
77,596 KB
testcase_22 AC 373 ms
77,152 KB
testcase_23 TLE -
testcase_24 AC 308 ms
77,132 KB
testcase_25 AC 622 ms
77,180 KB
testcase_26 AC 253 ms
77,160 KB
testcase_27 AC 84 ms
76,508 KB
testcase_28 AC 95 ms
76,596 KB
testcase_29 AC 84 ms
76,796 KB
testcase_30 AC 364 ms
76,996 KB
testcase_31 AC 346 ms
77,080 KB
testcase_32 AC 345 ms
77,352 KB
testcase_33 AC 336 ms
77,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# A*B
def mat_mul(A, B, mod):
    C = [[0]*len(B[0]) for i in range(len(A))]
    for i in range(len(A)):
        for k in range(len(B)):
            for j in range(len(B[0])):
                C[i][j] = (C[i][j] + A[i][k]*B[k][j])%mod
    return C

#A**n
def mat_pow(A, n, mod):
    B = [[0]*len(A) for i in range(len(A))]
    for i in range(len(A)):
        B[i][i] = 1
    while n > 0:
        if n & 1 == 1:
            B = mat_mul(A, B, mod)
        A = mat_mul(A, A, mod)
        n = n>>1
    return B

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

mod = 998244353

n, m, t = map(int, input().split())
A = [[0]*n for i in range(n)]
for i in range(m):
    u, v = map(int, input().split())
    A[u][v] = 1
    A[v][u] = 1

A = mat_pow(A, t, mod)
ans = A[0][0]%mod
print(ans)
0