結果

問題 No.1112 冥界の音楽
ユーザー mkawa2mkawa2
提出日時 2020-07-10 22:35:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,201 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 53,928 KB
最終ジャッジ日時 2024-04-19 17:48:54
合計ジャッジ時間 33,534 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 456 ms
50,996 KB
testcase_01 AC 454 ms
44,044 KB
testcase_02 AC 480 ms
43,916 KB
testcase_03 AC 471 ms
44,044 KB
testcase_04 AC 464 ms
43,660 KB
testcase_05 AC 467 ms
43,792 KB
testcase_06 AC 603 ms
43,788 KB
testcase_07 AC 463 ms
44,428 KB
testcase_08 AC 478 ms
44,048 KB
testcase_09 AC 574 ms
44,176 KB
testcase_10 AC 477 ms
43,784 KB
testcase_11 AC 483 ms
44,300 KB
testcase_12 AC 464 ms
43,664 KB
testcase_13 AC 458 ms
43,920 KB
testcase_14 TLE -
testcase_15 AC 668 ms
44,172 KB
testcase_16 AC 473 ms
44,052 KB
testcase_17 AC 971 ms
43,760 KB
testcase_18 AC 977 ms
43,788 KB
testcase_19 AC 477 ms
44,224 KB
testcase_20 AC 569 ms
44,176 KB
testcase_21 AC 1,976 ms
44,688 KB
testcase_22 TLE -
testcase_23 AC 796 ms
44,048 KB
testcase_24 AC 461 ms
43,916 KB
testcase_25 AC 459 ms
43,788 KB
testcase_26 AC 453 ms
44,176 KB
testcase_27 AC 455 ms
43,664 KB
testcase_28 AC 479 ms
44,176 KB
testcase_29 AC 460 ms
43,784 KB
testcase_30 TLE -
testcase_31 AC 486 ms
44,292 KB
testcase_32 TLE -
testcase_33 AC 475 ms
44,052 KB
testcase_34 AC 473 ms
44,048 KB
testcase_35 AC 476 ms
44,172 KB
testcase_36 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

md=10**9+7
k,m,n=MI()
pqr=LLI(m)
if n==3:
    ans=0
    for p,q,r in pqr:
        if p==1 and r==1:ans+=1
    print(ans)
    exit()
to=np.zeros((m,m),dtype=object)
for i in range(m):
    for j in range(m):
        if pqr[i][1:]==pqr[j][:2]:to[i][j]=1
#print(to)
cnt=np.eye(m,dtype=object)
n-=3
while n:
    if n&1:cnt=np.dot(cnt,to)%md
    to=np.dot(to,to)%md
    n>>=1
#print(cnt)

start=[]
end=[]
for i,(p,q,r) in enumerate(pqr):
    if p==1:start.append(i)
    if r==1:end.append(i)
ans=0
for s in start:
    for e in end:
        ans+=cnt[s][e]
        ans%=md
print(ans)
0