結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー stngstng
提出日時 2022-05-15 13:51:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 698 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 17,508 KB
最終ジャッジ日時 2023-10-09 22:14:32
合計ジャッジ時間 14,154 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
17,508 KB
testcase_01 AC 15 ms
7,940 KB
testcase_02 AC 16 ms
7,860 KB
testcase_03 AC 15 ms
7,860 KB
testcase_04 AC 386 ms
8,540 KB
testcase_05 AC 14 ms
7,760 KB
testcase_06 AC 14 ms
7,856 KB
testcase_07 AC 14 ms
7,836 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 #

def dot(A1,A2,n,mod):
  # n:行列のサイズ
  A = [[0]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      for k in range(n):
        A[i][j] += A1[i][k]*A2[k][j]
        A[i][j] %= mod
  return A

def pow_mat(A,k,n,mod):
  # A:累乗する行列, k:累乗数, n:行列Aのサイズ
  P = [[0]*n for _ in range(n)]
  for i in range(n): P[i][i] = 1
  while k:
    if k&1: P = dot(P,A,n,mod)
    A = dot(A,A,n,mod)
    k >>= 1
  return P

n,m,T = map(int,input().split())
st = [[] for i in range(n)]
mod = 998244353

st = [[0]*n for i in range(n)]

for i in range(m):
    s,t = map(int,input().split())
    st[s][t] = 1
    st[t][s] = 1

A = pow_mat(st,T,n,mod)
 
print(A[0][0])
0