結果

問題 No.1112 冥界の音楽
ユーザー mkawa2mkawa2
提出日時 2020-07-10 23:06:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 791 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 44,496 KB
最終ジャッジ日時 2024-04-19 23:27:46
合計ジャッジ時間 20,788 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 463 ms
44,292 KB
testcase_01 AC 465 ms
44,300 KB
testcase_02 AC 461 ms
44,048 KB
testcase_03 AC 456 ms
44,296 KB
testcase_04 AC 460 ms
44,036 KB
testcase_05 AC 457 ms
43,784 KB
testcase_06 AC 449 ms
44,172 KB
testcase_07 AC 454 ms
44,168 KB
testcase_08 AC 447 ms
44,292 KB
testcase_09 AC 455 ms
43,904 KB
testcase_10 AC 461 ms
44,176 KB
testcase_11 AC 462 ms
44,176 KB
testcase_12 AC 462 ms
43,880 KB
testcase_13 AC 453 ms
44,036 KB
testcase_14 AC 522 ms
43,784 KB
testcase_15 AC 490 ms
44,176 KB
testcase_16 AC 482 ms
43,912 KB
testcase_17 AC 506 ms
44,164 KB
testcase_18 AC 497 ms
44,292 KB
testcase_19 AC 477 ms
44,424 KB
testcase_20 AC 490 ms
44,304 KB
testcase_21 AC 524 ms
44,172 KB
testcase_22 AC 528 ms
43,908 KB
testcase_23 AC 481 ms
44,048 KB
testcase_24 AC 555 ms
44,300 KB
testcase_25 AC 550 ms
43,912 KB
testcase_26 AC 551 ms
44,168 KB
testcase_27 AC 551 ms
44,176 KB
testcase_28 AC 566 ms
44,044 KB
testcase_29 AC 551 ms
43,780 KB
testcase_30 AC 636 ms
44,172 KB
testcase_31 AC 541 ms
44,160 KB
testcase_32 AC 626 ms
44,024 KB
testcase_33 AC 552 ms
44,296 KB
testcase_34 AC 542 ms
43,784 KB
testcase_35 AC 549 ms
43,912 KB
testcase_36 AC 791 ms
44,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import sys

int1 = lambda x: int(x) - 1
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main(n):
    if n == 3:
        ans = 0
        for p, q, r in pqr:
            if p == 0 and r == 0: ans += 1
        print(ans)
        exit()

    to = np.zeros((36, 36), dtype=object)
    #print(pqr)
    for p,q,r in pqr:to[p*6+q][q*6+r]=1
    #print(to)
    cnt = np.eye(36, dtype=object)
    n -= 2
    while n:
        if n & 1: cnt = np.dot(cnt, to) % md
        to = np.dot(to, to) % md
        n >>= 1
    #print(cnt)

    ans = 0
    for i in range(6):
        for j in range(6):
            ans += cnt[i][j*6]
            ans %= md
    print(ans)

md=10**9+7
k,m,n=MI()
pqr=LLI(m)
main(n)
0