結果

問題 No.1749 ラムドスウイルスの感染拡大
ユーザー ああいい
提出日時 2021-12-03 19:26:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 74,784 KB
最終ジャッジ日時 2024-07-06 01:02:37
合計ジャッジ時間 9,094 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 3 WA * 1 TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N,M,T = list(map(int,input().split()))
d = [[0] * N for _ in range(N)]
P = 998244353

for _ in range(M):
    s,t = list(map(int,input().split()))
    d[s][t] = 1
    d[t][s] = 1
M = np.matrix(d)
power = [0] * 10
power[0] = M
for i in range(1,10):
    power[i] = power[i-1] ** 2 % P
def calc(n):
    ans = None
    flag = False
    for i in range(10):
        if n & (1 << i):
            if flag == False:
                ans = power[i]
                flag = True
            else:
                ans = ans * power[i] % P
    return ans

if T == 0:
    print(1)
else:
    print(calc(T)[0,0])

0