結果

問題 No.1112 冥界の音楽
ユーザー takakintakakin
提出日時 2020-07-10 22:20:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 73,904 KB
最終ジャッジ日時 2024-04-19 17:32:32
合計ジャッジ時間 2,690 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
59,776 KB
testcase_01 AC 34 ms
52,096 KB
testcase_02 AC 33 ms
52,352 KB
testcase_03 AC 33 ms
52,736 KB
testcase_04 AC 32 ms
52,352 KB
testcase_05 AC 32 ms
52,660 KB
testcase_06 AC 42 ms
60,800 KB
testcase_07 AC 33 ms
52,352 KB
testcase_08 AC 36 ms
58,496 KB
testcase_09 AC 37 ms
60,116 KB
testcase_10 AC 34 ms
52,480 KB
testcase_11 AC 46 ms
60,160 KB
testcase_12 AC 38 ms
52,608 KB
testcase_13 AC 43 ms
60,672 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 34 ms
52,096 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 34 ms
52,864 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 44 ms
61,696 KB
testcase_24 AC 33 ms
52,736 KB
testcase_25 AC 33 ms
52,352 KB
testcase_26 AC 41 ms
61,696 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 34 ms
52,864 KB
testcase_30 WA -
testcase_31 AC 42 ms
61,696 KB
testcase_32 WA -
testcase_33 AC 44 ms
61,824 KB
testcase_34 AC 36 ms
52,352 KB
testcase_35 AC 45 ms
61,696 KB
testcase_36 AC 96 ms
73,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
k,m,n=map(int,input().split())
mod=10**9+7
PQR=[[int(i)-1 for i in input().split()] for _ in range(m)]

A=[[0]*(k**2) for _ in range(k**2)]
for p,q,r in PQR:
  s,g=p*k+q,q*k+r
  A[g][s]+=1

def mul(a,b):
  c=[[0]*len(b[0]) for i in range(len(a))]
  for i in range(len(a)):
    for k in range(len(b)):
      for j in range(len(b[0])):
        c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod
  return c

def matrix_pow(a,x):
  b=[[0]*len(a) for i in range(len(a))]
  for i in range(len(a)):
    b[i][i] = 1
	
  while x>0:
    if x&1==1:
      b=mul(a,b)
    a=mul(a,a)
    x>>=1		
  return b

AN=matrix_pow(A,n-2)
Ans=[0]*(k**2)
for i in range(k**2):
  for j in range(k):
    Ans[i]+=AN[i][j]
  Ans[i]=Ans[i]%mod
ans=0
for i in range(k):
  ans+=Ans[i*k]
print(ans)

0