結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー Kome_soudouKome_soudou
提出日時 2022-03-11 01:20:08
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 763 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 78,572 KB
最終ジャッジ日時 2023-10-13 03:40:25
合計ジャッジ時間 28,007 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,412 KB
testcase_01 AC 73 ms
71,636 KB
testcase_02 AC 76 ms
75,800 KB
testcase_03 AC 78 ms
76,264 KB
testcase_04 AC 138 ms
76,432 KB
testcase_05 AC 72 ms
71,288 KB
testcase_06 AC 73 ms
71,360 KB
testcase_07 AC 71 ms
71,364 KB
testcase_08 AC 472 ms
77,700 KB
testcase_09 AC 472 ms
77,536 KB
testcase_10 AC 474 ms
77,600 KB
testcase_11 AC 380 ms
77,500 KB
testcase_12 AC 499 ms
77,312 KB
testcase_13 AC 476 ms
77,528 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,562 ms
77,672 KB
testcase_21 AC 1,815 ms
78,020 KB
testcase_22 AC 385 ms
77,252 KB
testcase_23 TLE -
testcase_24 AC 319 ms
77,228 KB
testcase_25 AC 645 ms
76,944 KB
testcase_26 AC 264 ms
77,052 KB
testcase_27 AC 87 ms
76,304 KB
testcase_28 AC 101 ms
76,624 KB
testcase_29 AC 89 ms
76,516 KB
testcase_30 AC 378 ms
76,996 KB
testcase_31 AC 360 ms
77,264 KB
testcase_32 AC 355 ms
77,168 KB
testcase_33 AC 349 ms
77,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

# 行列の乗算(mod)
def mat_mul(a, b, 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

# 行列の累乗(mod)
def mat_pow(a, n, mod):
	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, mod)
		a = mat_mul(a, a, mod)
		n >>= 1
	return b

N, M, T = map(int, input().split())
G = [[0 for j in range(N)] for i in range(N)]
mod = 998244353
for i in range(M):
	s, t = map(int, input().split())
	G[s][t] = 1
	G[t][s] = 1

ans = mat_pow(G, T, mod)
print(ans[0][0])
0