結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー Mine
提出日時 2022-01-07 22:42:01
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 489 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,524 KB
最終ジャッジ日時 2024-11-14 08:57:26
合計ジャッジ時間 21,906 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

n, m, t = map(int, input().split())
mod = 998244353
graph = np.zeros([n, n], dtype="int64")
for i in range(m):
    a, b = map(int, input().split())
    graph[a][b] = 1
    graph[b][a] = 1

ans = np.identity(n, dtype="int64")
t_bin = bin(t)[2:]
for i in range(t.bit_length())[::-1]:
    if t_bin[i] == "1":
        ans = graph @ ans
        ans %= mod
    graph = graph @ graph
    graph %= mod
    
b = np.zeros([n, 1], dtype="int64")
b[0][0] = 1
print((ans @ b)[0][0])
0