結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー stngstng
提出日時 2022-05-15 14:02:15
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 716 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 77,912 KB
最終ジャッジ日時 2023-10-09 22:25:37
合計ジャッジ時間 27,339 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,240 KB
testcase_01 AC 74 ms
71,436 KB
testcase_02 AC 78 ms
75,500 KB
testcase_03 AC 81 ms
76,104 KB
testcase_04 AC 132 ms
76,236 KB
testcase_05 AC 73 ms
71,364 KB
testcase_06 AC 76 ms
71,496 KB
testcase_07 AC 74 ms
70,952 KB
testcase_08 AC 464 ms
77,052 KB
testcase_09 AC 470 ms
77,124 KB
testcase_10 AC 465 ms
77,056 KB
testcase_11 AC 374 ms
77,224 KB
testcase_12 AC 496 ms
77,116 KB
testcase_13 AC 470 ms
76,932 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,547 ms
77,356 KB
testcase_21 AC 1,805 ms
77,312 KB
testcase_22 AC 381 ms
76,816 KB
testcase_23 TLE -
testcase_24 AC 312 ms
76,872 KB
testcase_25 AC 641 ms
76,852 KB
testcase_26 AC 260 ms
76,824 KB
testcase_27 AC 86 ms
76,392 KB
testcase_28 AC 98 ms
76,320 KB
testcase_29 AC 86 ms
76,156 KB
testcase_30 AC 374 ms
76,588 KB
testcase_31 AC 355 ms
77,112 KB
testcase_32 AC 348 ms
76,752 KB
testcase_33 AC 345 ms
76,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

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())
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