結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
70,884 KB
testcase_01 AC 67 ms
71,000 KB
testcase_02 AC 71 ms
75,332 KB
testcase_03 AC 74 ms
75,592 KB
testcase_04 AC 125 ms
75,612 KB
testcase_05 AC 63 ms
71,028 KB
testcase_06 AC 73 ms
71,084 KB
testcase_07 AC 66 ms
71,100 KB
testcase_08 AC 459 ms
77,084 KB
testcase_09 AC 448 ms
77,312 KB
testcase_10 AC 454 ms
77,124 KB
testcase_11 AC 354 ms
76,828 KB
testcase_12 AC 482 ms
76,836 KB
testcase_13 AC 475 ms
76,936 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,555 ms
77,240 KB
testcase_21 AC 1,755 ms
77,088 KB
testcase_22 AC 363 ms
76,688 KB
testcase_23 TLE -
testcase_24 AC 312 ms
76,580 KB
testcase_25 AC 635 ms
76,652 KB
testcase_26 AC 254 ms
76,604 KB
testcase_27 AC 83 ms
75,672 KB
testcase_28 AC 93 ms
76,060 KB
testcase_29 AC 79 ms
75,872 KB
testcase_30 AC 376 ms
76,608 KB
testcase_31 AC 353 ms
76,748 KB
testcase_32 AC 347 ms
76,588 KB
testcase_33 AC 329 ms
76,456 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 mat_mul(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
"""

# 行列の累乗(mod)
def mat_pow(a, n):
	b = [[0 for j in range(len(a))] for i in range(len(a))]
	for i in range(len(a)):
		b[i][i] = 1
	while n > 0:
		if n & 1:
			b = mat_mul(b, a, n, mod)
		a = mat_mul(a, a, n, mod)
		n >>= 1
	return b

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 = mat_pow(st,T)

print(A[0][0])
0