結果
問題 |
No.1112 冥界の音楽
|
ユーザー |
![]() |
提出日時 | 2020-07-10 23:06:17 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 893 ms / 2,000 ms |
コード長 | 848 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 44,548 KB |
最終ジャッジ日時 | 2024-10-11 18:05:52 |
合計ジャッジ時間 | 24,499 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
import numpy as np import sys int1 = lambda x: int(x) - 1 def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(n): if n == 3: ans = 0 for p, q, r in pqr: if p == 0 and r == 0: ans += 1 print(ans) exit() to = np.zeros((36, 36), dtype=object) #print(pqr) for p,q,r in pqr:to[p*6+q][q*6+r]=1 #print(to) cnt = np.eye(36, dtype=object) n -= 2 while n: if n & 1: cnt = np.dot(cnt, to) % md to = np.dot(to, to) % md n >>= 1 #print(cnt) ans = 0 for i in range(6): for j in range(6): ans += cnt[i][j*6] ans %= md print(ans) md=10**9+7 k,m,n=MI() pqr=LLI(m) main(n)