結果

問題 No.1112 冥界の音楽
ユーザー qumazakiqumazaki
提出日時 2020-07-11 02:08:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 940 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 77,104 KB
最終ジャッジ日時 2024-04-20 04:58:14
合計ジャッジ時間 4,932 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
73,344 KB
testcase_01 AC 94 ms
71,936 KB
testcase_02 AC 93 ms
73,664 KB
testcase_03 AC 86 ms
71,552 KB
testcase_04 AC 89 ms
73,728 KB
testcase_05 AC 89 ms
73,600 KB
testcase_06 AC 91 ms
73,600 KB
testcase_07 AC 84 ms
72,448 KB
testcase_08 AC 84 ms
71,680 KB
testcase_09 AC 85 ms
72,064 KB
testcase_10 AC 86 ms
72,064 KB
testcase_11 AC 89 ms
73,984 KB
testcase_12 AC 93 ms
73,344 KB
testcase_13 AC 89 ms
72,192 KB
testcase_14 AC 99 ms
76,672 KB
testcase_15 AC 99 ms
76,928 KB
testcase_16 AC 100 ms
76,884 KB
testcase_17 AC 98 ms
76,848 KB
testcase_18 AC 101 ms
76,804 KB
testcase_19 AC 100 ms
76,672 KB
testcase_20 AC 100 ms
76,944 KB
testcase_21 AC 100 ms
77,056 KB
testcase_22 AC 102 ms
76,816 KB
testcase_23 AC 100 ms
77,104 KB
testcase_24 AC 117 ms
76,848 KB
testcase_25 AC 113 ms
77,080 KB
testcase_26 AC 108 ms
76,672 KB
testcase_27 AC 107 ms
76,928 KB
testcase_28 AC 113 ms
76,800 KB
testcase_29 AC 112 ms
76,816 KB
testcase_30 AC 106 ms
76,940 KB
testcase_31 AC 103 ms
77,028 KB
testcase_32 AC 112 ms
76,732 KB
testcase_33 AC 110 ms
76,800 KB
testcase_34 AC 107 ms
76,928 KB
testcase_35 AC 109 ms
77,020 KB
testcase_36 AC 117 ms
76,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

k,m,n = map(int,readline().split())
pqr = list(map(int,read().split()))
mod = 10**9+7

mat = [[0] * 36 for _ in range(36)]
it = iter(pqr)
for p,q,r in zip(it,it,it):
    p,q,r = p-1,q-1,r-1
    mat[(p*6+q)][(q*6+r)] = 1

def dot_mod(a,b):
    res = [[0] * 36 for _ in range(36)]
    for i in range(36):
        for j in range(36):
            for k in range(36):
                res[i][j] += a[i][k] * b[k][j]
                res[i][j] %= mod
    return res

mat_ex = [mat]
for i in range(65):
    mat_ex.append( dot_mod(mat_ex[-1],mat_ex[-1]) )

mat_n = [[0] * 36 for _ in range(36)]
for i in range(36):
    mat_n[i][i] = 1

x = n-2
for i in range(65):
    if((x>>i)&1):
        mat_n = dot_mod(mat_n,mat_ex[i])

ans = 0
for i in range(6):
    for j in range(6):
        ans += mat_n[i][6*j]
        ans %= mod

print(ans)
0