結果

問題 No.1112 冥界の音楽
ユーザー SSlimeSSlime
提出日時 2020-07-11 09:56:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 677 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 44,552 KB
最終ジャッジ日時 2024-04-20 19:48:50
合計ジャッジ時間 25,651 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 521 ms
43,892 KB
testcase_01 AC 523 ms
43,648 KB
testcase_02 AC 524 ms
44,292 KB
testcase_03 AC 530 ms
43,776 KB
testcase_04 AC 532 ms
44,156 KB
testcase_05 AC 528 ms
43,908 KB
testcase_06 AC 542 ms
44,156 KB
testcase_07 AC 531 ms
43,908 KB
testcase_08 AC 526 ms
44,028 KB
testcase_09 AC 528 ms
43,908 KB
testcase_10 AC 527 ms
44,028 KB
testcase_11 AC 530 ms
44,028 KB
testcase_12 AC 524 ms
43,776 KB
testcase_13 AC 547 ms
43,908 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 534 ms
44,160 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 525 ms
43,772 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 539 ms
44,028 KB
testcase_25 AC 533 ms
44,412 KB
testcase_26 AC 534 ms
44,036 KB
testcase_27 AC 527 ms
43,900 KB
testcase_28 AC 535 ms
44,160 KB
testcase_29 AC 532 ms
43,780 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 531 ms
43,900 KB
testcase_34 AC 527 ms
44,408 KB
testcase_35 AC 531 ms
43,908 KB
testcase_36 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

k, m, n = map(int, input().split())
P = [tuple(map(int, input().split())) for i in range(m)]

X = np.array([[0] * m for i in range(m)])

A = np.array([[0] for i in range(m)])
end = []
for i,(p,q,r) in enumerate(P):
    for j in range(m):
        if P[j][0] == q and P[j][1] == r:
            X[j][i] += 1
    if p == 1:
        A[i][0] += 1
    if r == 1:
        end.append(i)
mod = 10**9 + 7
n -= 3
res = np.array([[0]*i + [1] + [0]*(m-i-1) for i in range(m)])
while n > 0:
    if n & 1:
        res = np.dot(X, res) % mod
    X = np.dot(X, X) % mod
    n >>= 1

B = np.dot(res, A) % mod
ans = 0
for i in end:
    ans += B[i][0]
    ans %= mod
print(ans)
0