結果

問題 No.1112 冥界の音楽
ユーザー anagohirameanagohirame
提出日時 2020-07-10 23:00:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,608 KB
最終ジャッジ日時 2024-04-19 21:58:34
合計ジャッジ時間 19,251 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 446 ms
43,832 KB
testcase_01 AC 453 ms
44,340 KB
testcase_02 AC 444 ms
44,228 KB
testcase_03 AC 465 ms
44,348 KB
testcase_04 AC 453 ms
44,352 KB
testcase_05 AC 446 ms
44,224 KB
testcase_06 AC 441 ms
44,228 KB
testcase_07 AC 452 ms
44,224 KB
testcase_08 AC 447 ms
44,344 KB
testcase_09 AC 458 ms
44,216 KB
testcase_10 AC 455 ms
43,960 KB
testcase_11 AC 444 ms
44,224 KB
testcase_12 AC 444 ms
43,964 KB
testcase_13 AC 439 ms
44,604 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 452 ms
44,224 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 455 ms
43,968 KB
testcase_20 AC 461 ms
44,100 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 469 ms
44,348 KB
testcase_25 AC 473 ms
44,096 KB
testcase_26 AC 468 ms
44,224 KB
testcase_27 AC 457 ms
44,344 KB
testcase_28 AC 448 ms
44,228 KB
testcase_29 AC 451 ms
43,832 KB
testcase_30 WA -
testcase_31 AC 458 ms
43,832 KB
testcase_32 WA -
testcase_33 AC 454 ms
44,224 KB
testcase_34 AC 446 ms
43,968 KB
testcase_35 AC 450 ms
44,348 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import sys
def input():
	return sys.stdin.readline()[:-1]

MOD = 10**9+7

def mat_pow(mat, exp):
	size = len(mat)
	res = np.eye(size, dtype=int)
	cnt = 0
	while (1<<cnt) <= exp:
		if (exp>>cnt)&1:
			res = res @ mat
			res %= MOD
		mat = mat @ mat
		mat %= MOD
		cnt += 1
	return res

k, m, n = map(int, input().split())
pre = np.zeros((k*k, 1), dtype=int)
for i in range(k):
	pre[i][0] = 1
mat = np.zeros((k*k, k*k), dtype=int)
for _ in range(m):
	p, q, r = map(int, input().split())
	mat[(q-1)*k + r-1][(p-1)*k + q-1] += 1
res = mat_pow(mat, n-2) @ pre
ans = 0
for i in range(k):
	ans += res[i*k][0]
	ans %= MOD
print(ans)
0