結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー tktk_snsntktk_snsn
提出日時 2021-11-20 17:53:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,102 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 77,756 KB
最終ジャッジ日時 2023-09-02 13:32:15
合計ジャッジ時間 15,041 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,144 KB
testcase_01 AC 74 ms
71,156 KB
testcase_02 AC 76 ms
75,580 KB
testcase_03 AC 78 ms
76,068 KB
testcase_04 AC 104 ms
75,980 KB
testcase_05 AC 71 ms
71,028 KB
testcase_06 AC 71 ms
70,868 KB
testcase_07 AC 72 ms
71,156 KB
testcase_08 AC 259 ms
77,084 KB
testcase_09 AC 258 ms
77,032 KB
testcase_10 AC 261 ms
77,104 KB
testcase_11 AC 216 ms
77,132 KB
testcase_12 AC 270 ms
77,144 KB
testcase_13 AC 260 ms
77,112 KB
testcase_14 AC 1,026 ms
77,356 KB
testcase_15 AC 1,051 ms
77,572 KB
testcase_16 AC 1,065 ms
77,640 KB
testcase_17 AC 1,072 ms
77,376 KB
testcase_18 AC 1,102 ms
77,756 KB
testcase_19 AC 1,060 ms
77,588 KB
testcase_20 AC 756 ms
77,532 KB
testcase_21 AC 867 ms
77,492 KB
testcase_22 AC 217 ms
76,572 KB
testcase_23 AC 1,011 ms
77,744 KB
testcase_24 AC 187 ms
76,976 KB
testcase_25 AC 337 ms
77,020 KB
testcase_26 AC 166 ms
76,528 KB
testcase_27 AC 87 ms
76,148 KB
testcase_28 AC 94 ms
76,252 KB
testcase_29 AC 86 ms
75,828 KB
testcase_30 AC 218 ms
76,764 KB
testcase_31 AC 208 ms
76,764 KB
testcase_32 AC 206 ms
76,924 KB
testcase_33 AC 209 ms
76,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
mod = 998244353


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


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


N, M, T = map(int, input().split())
A = [[0] * N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    A[a][b] = 1
    A[b][a] = 1

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