結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー tktk_snsntktk_snsn
提出日時 2021-11-20 17:53:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 805 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 17,412 KB
最終ジャッジ日時 2023-09-02 13:31:07
合計ジャッジ時間 15,425 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
17,412 KB
testcase_01 AC 16 ms
7,776 KB
testcase_02 AC 17 ms
7,860 KB
testcase_03 AC 16 ms
7,868 KB
testcase_04 AC 428 ms
8,472 KB
testcase_05 AC 17 ms
7,840 KB
testcase_06 AC 16 ms
7,832 KB
testcase_07 AC 17 ms
7,820 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
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 #

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