結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-11-20 16:36:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,118 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 78,148 KB
最終ジャッジ日時 2023-09-02 11:46:19
合計ジャッジ時間 16,654 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,420 KB
testcase_01 AC 78 ms
71,352 KB
testcase_02 AC 84 ms
75,824 KB
testcase_03 AC 86 ms
76,100 KB
testcase_04 AC 127 ms
76,348 KB
testcase_05 AC 79 ms
71,116 KB
testcase_06 AC 77 ms
71,364 KB
testcase_07 AC 77 ms
71,124 KB
testcase_08 AC 279 ms
77,248 KB
testcase_09 AC 281 ms
77,148 KB
testcase_10 AC 278 ms
77,236 KB
testcase_11 AC 246 ms
77,028 KB
testcase_12 AC 300 ms
77,300 KB
testcase_13 AC 289 ms
77,104 KB
testcase_14 AC 1,049 ms
78,148 KB
testcase_15 AC 1,072 ms
77,900 KB
testcase_16 AC 1,081 ms
77,512 KB
testcase_17 AC 1,081 ms
78,028 KB
testcase_18 AC 1,118 ms
77,760 KB
testcase_19 AC 1,069 ms
77,800 KB
testcase_20 AC 767 ms
77,524 KB
testcase_21 AC 876 ms
77,288 KB
testcase_22 AC 236 ms
76,756 KB
testcase_23 AC 1,023 ms
78,008 KB
testcase_24 AC 196 ms
76,744 KB
testcase_25 AC 349 ms
77,052 KB
testcase_26 AC 174 ms
76,996 KB
testcase_27 AC 90 ms
76,296 KB
testcase_28 AC 102 ms
76,368 KB
testcase_29 AC 93 ms
76,308 KB
testcase_30 AC 238 ms
76,880 KB
testcase_31 AC 231 ms
77,072 KB
testcase_32 AC 228 ms
77,088 KB
testcase_33 AC 220 ms
77,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

def mat_mul(a, b):
    n_a, m_a = len(a), len(a[0])
    n_b, m_b = len(b), len(b[0])
    res = [[0] * m_b for i in range(n_a)]
    for i in range(n_a):
        for k in range(m_a):
            for j in range(m_b):
                res[i][j] += a[i][k] * b[k][j]
                res[i][j] %= mod
    return res

def mat_pow(a, k):
    if k == 1: return a
    n = len(a)
    res = [[0] * n for i in range(n)]
    for i in range(n):
        res[i][i] = 1
    while k:
        if k & 1:
            res = mat_mul(res, a)
        a = mat_mul(a, a)
        k >>= 1
    return res

n, m, t = map(int, input().split())
G = [[0] * n for i in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	G[a][b] = 1
	G[b][a] = 1
G = mat_pow(G, t)
b = [[0] * n for i in range(n)]
b[0][0] = 1
G = mat_mul(G, b)
print(G[0][0])
0