結果

問題 No.1112 冥界の音楽
ユーザー titiatitia
提出日時 2020-07-11 01:47:09
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 1,153 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 17,144 KB
最終ジャッジ日時 2023-08-02 03:43:43
合計ジャッジ時間 4,102 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
12,480 KB
testcase_01 AC 17 ms
8,096 KB
testcase_02 AC 15 ms
8,056 KB
testcase_03 AC 18 ms
8,052 KB
testcase_04 AC 17 ms
8,056 KB
testcase_05 AC 18 ms
8,044 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
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=[[None 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=[[None 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