結果

問題 No.1112 冥界の音楽
ユーザー SSlimeSSlime
提出日時 2020-07-11 09:56:34
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 677 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 31,632 KB
最終ジャッジ日時 2023-08-02 19:40:51
合計ジャッジ時間 10,081 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
29,628 KB
testcase_01 AC 118 ms
29,576 KB
testcase_02 AC 124 ms
29,576 KB
testcase_03 AC 122 ms
29,576 KB
testcase_04 AC 121 ms
29,636 KB
testcase_05 AC 120 ms
29,528 KB
testcase_06 AC 125 ms
30,204 KB
testcase_07 AC 116 ms
29,616 KB
testcase_08 AC 119 ms
29,564 KB
testcase_09 AC 117 ms
29,696 KB
testcase_10 AC 118 ms
29,704 KB
testcase_11 AC 119 ms
29,604 KB
testcase_12 AC 124 ms
29,516 KB
testcase_13 AC 132 ms
30,644 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 121 ms
29,624 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 116 ms
29,632 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 118 ms
29,508 KB
testcase_25 AC 126 ms
29,624 KB
testcase_26 AC 123 ms
29,636 KB
testcase_27 AC 119 ms
29,532 KB
testcase_28 AC 118 ms
29,636 KB
testcase_29 AC 118 ms
29,608 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 117 ms
29,584 KB
testcase_34 AC 117 ms
29,568 KB
testcase_35 AC 117 ms
29,688 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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