結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー stngstng
提出日時 2022-05-15 14:03:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 977 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 78,684 KB
最終ジャッジ日時 2023-10-09 22:29:45
合計ジャッジ時間 28,720 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,060 KB
testcase_01 AC 75 ms
71,172 KB
testcase_02 AC 83 ms
75,700 KB
testcase_03 AC 82 ms
76,196 KB
testcase_04 AC 138 ms
76,192 KB
testcase_05 AC 75 ms
71,240 KB
testcase_06 AC 77 ms
70,952 KB
testcase_07 AC 75 ms
71,160 KB
testcase_08 AC 519 ms
77,352 KB
testcase_09 AC 487 ms
77,252 KB
testcase_10 AC 491 ms
77,232 KB
testcase_11 AC 394 ms
77,540 KB
testcase_12 AC 518 ms
77,456 KB
testcase_13 AC 495 ms
77,480 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,634 ms
77,492 KB
testcase_21 AC 1,897 ms
77,416 KB
testcase_22 AC 402 ms
77,052 KB
testcase_23 TLE -
testcase_24 AC 331 ms
77,000 KB
testcase_25 AC 675 ms
77,076 KB
testcase_26 AC 275 ms
77,204 KB
testcase_27 AC 92 ms
76,380 KB
testcase_28 AC 103 ms
76,120 KB
testcase_29 AC 94 ms
76,260 KB
testcase_30 AC 399 ms
76,940 KB
testcase_31 AC 381 ms
77,012 KB
testcase_32 AC 372 ms
77,056 KB
testcase_33 AC 362 ms
76,644 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
"""
# 行列の乗算(mod)
def dot(a, b, n, mod):
	I, K, J = len(a), len(b), len(b[0])
	c = [[0 for j in range(J)] for i in range(I)]
	for i in range(I):
		for k in range(K):
			for j in range(J):
				c[i][j] += a[i][k] * b[k][j]
				c[i][j] %= mod
	return c

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