結果

問題 No.1112 冥界の音楽
ユーザー titiatitia
提出日時 2020-07-11 01:56:09
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,147 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 93,088 KB
最終ジャッジ日時 2023-08-02 04:41:53
合計ジャッジ時間 6,301 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
80,808 KB
testcase_01 AC 72 ms
75,396 KB
testcase_02 AC 66 ms
71,636 KB
testcase_03 AC 73 ms
76,548 KB
testcase_04 AC 73 ms
76,348 KB
testcase_05 AC 75 ms
76,328 KB
testcase_06 AC 702 ms
82,136 KB
testcase_07 AC 70 ms
71,428 KB
testcase_08 AC 78 ms
76,332 KB
testcase_09 AC 194 ms
78,040 KB
testcase_10 AC 72 ms
75,472 KB
testcase_11 AC 158 ms
78,048 KB
testcase_12 AC 72 ms
75,400 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod=10**9+7

K,M,N=map(int,input().split())
CODE=[list(map(int,input().split())) for i in range(M)]

# 行列の計算(numpyを使えないとき,modを使用)
def prod(A,B,k,l,m):# A:k*l,B:l*m
    C=[[0 for i in range(m)] for j in range(k)]

    for i in range(k):
        for j in range(m):
            ANS=0
            for pl in range(l):
                ANS=(ANS+A[i][pl]*B[pl][j])%mod

            C[i][j]=ANS

    return C

def plus(A,B,k,l):# a,B:k*l
    C=[[0 for i in range(l)] for j in range(k)]

    for i in range(k):
        for j in range(l):
            C[i][j]=(A[i][j]+B[i][j])%mod

    return C

A=[[0]*M for i in range(M)]

for i in range(M):
    for j in range(M):
        if CODE[i][1:]==CODE[j][:2]:
            A[i][j]+=1

POWA=[A]

for i in range(60):
    POWA.append(prod(POWA[-1],POWA[-1],M,M,M)) # ベキを求めて

X=[[0]*M]
for i in range(M):
    if CODE[i][0]==1:
        X[0][i]+=1
n=N-3
while n:
    X=prod(X,POWA[n.bit_length()-1],1,M,M) # n乗の場合
    n-=1<<(n.bit_length()-1)

ANS=0
for i in range(M):
    if CODE[i][-1]==1:
        ANS+=X[0][i]
print(ANS%mod)
0