結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー stngstng
提出日時 2022-05-15 13:50:17
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,002 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 77,752 KB
最終ジャッジ日時 2023-10-09 22:14:17
合計ジャッジ時間 26,753 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,348 KB
testcase_01 AC 62 ms
71,096 KB
testcase_02 AC 83 ms
75,852 KB
testcase_03 AC 68 ms
76,168 KB
testcase_04 AC 129 ms
76,484 KB
testcase_05 AC 66 ms
71,256 KB
testcase_06 AC 63 ms
71,248 KB
testcase_07 AC 60 ms
71,160 KB
testcase_08 AC 420 ms
76,996 KB
testcase_09 AC 424 ms
76,940 KB
testcase_10 AC 411 ms
76,948 KB
testcase_11 AC 339 ms
77,384 KB
testcase_12 AC 451 ms
76,784 KB
testcase_13 AC 427 ms
77,156 KB
testcase_14 AC 1,983 ms
77,508 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,411 ms
77,188 KB
testcase_21 AC 1,615 ms
77,376 KB
testcase_22 AC 346 ms
76,840 KB
testcase_23 AC 1,871 ms
77,532 KB
testcase_24 AC 277 ms
76,832 KB
testcase_25 AC 575 ms
76,840 KB
testcase_26 AC 249 ms
76,672 KB
testcase_27 AC 75 ms
76,200 KB
testcase_28 AC 84 ms
76,280 KB
testcase_29 AC 77 ms
76,196 KB
testcase_30 AC 343 ms
76,932 KB
testcase_31 AC 322 ms
76,912 KB
testcase_32 AC 325 ms
77,004 KB
testcase_33 AC 321 ms
76,916 KB
権限があれば一括ダウンロードができます

ソースコード

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

"""
ct = [0]*n
ct[0] = 1

for i in range(T):
    nct = [0]*n
    for j in range(n):
        for k in st[j]:
            nct[j] += ct[k]
            nct[j] %= mod
    ct = nct[:]

print(ct[0])
"""

A = pow_mat(st,T,n,mod)
#ans = 0
"""
for i in range(n):
    for j in range(n):
        ans += A[i][j]
        ans %= mod
"""        
print(A[0][0])
0