結果
問題 |
No.1340 おーじ君をさがせ
|
ユーザー |
![]() |
提出日時 | 2021-01-16 03:57:56 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 778 bytes |
コンパイル時間 | 725 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 78,208 KB |
最終ジャッジ日時 | 2024-11-26 22:27:32 |
合計ジャッジ時間 | 5,782 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 59 |
ソースコード
mod = 10**9+7 def main(): n, m, t = map(int, input().split()) A = [[0]*n for i in range(n)] for i in range(m): a, b = map(int, input().split()) A[b][a] = 1 #print(A) # A*B import numpy as np #A**n def mat_pow(A, n, mod): size = len(A) res = np.eye(size, dtype=np.object) while n > 0: if n & 1 == 1: res = res @ A res %= mod A = A @ A A %= mod n = n>>1 return res X = [0]*n X[0] = 1 X = np.array(X) A = np.array(A) A = mat_pow(A, t, mod) ans = 0 for i in range(n): s = A[i]@X if s: ans += 1 #print(A) print(ans) if __name__ == '__main__': main()