結果

問題 No.1340 おーじ君をさがせ
ユーザー maspymaspy
提出日時 2020-09-24 23:29:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 592 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 60,192 KB
最終ジャッジ日時 2023-08-17 19:34:09
合計ジャッジ時間 14,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 295 ms
29,720 KB
testcase_01 WA -
testcase_02 AC 130 ms
29,844 KB
testcase_03 AC 129 ms
29,852 KB
testcase_04 AC 129 ms
29,724 KB
testcase_05 AC 130 ms
29,712 KB
testcase_06 AC 132 ms
29,768 KB
testcase_07 AC 130 ms
29,696 KB
testcase_08 AC 131 ms
29,600 KB
testcase_09 WA -
testcase_10 AC 132 ms
29,716 KB
testcase_11 WA -
testcase_12 AC 137 ms
29,696 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 142 ms
29,696 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 130 ms
29,844 KB
testcase_21 AC 153 ms
30,712 KB
testcase_22 AC 178 ms
30,372 KB
testcase_23 AC 154 ms
30,808 KB
testcase_24 AC 213 ms
30,116 KB
testcase_25 AC 142 ms
30,472 KB
testcase_26 AC 138 ms
30,204 KB
testcase_27 AC 138 ms
29,956 KB
testcase_28 AC 143 ms
30,548 KB
testcase_29 AC 136 ms
29,848 KB
testcase_30 AC 156 ms
30,728 KB
testcase_31 AC 217 ms
31,052 KB
testcase_32 AC 214 ms
30,880 KB
testcase_33 AC 215 ms
30,852 KB
testcase_34 AC 211 ms
31,004 KB
testcase_35 AC 225 ms
31,004 KB
testcase_36 WA -
testcase_37 AC 141 ms
29,936 KB
testcase_38 AC 216 ms
29,932 KB
testcase_39 AC 159 ms
31,136 KB
testcase_40 AC 162 ms
30,972 KB
testcase_41 AC 165 ms
30,976 KB
testcase_42 AC 133 ms
29,856 KB
testcase_43 AC 132 ms
29,820 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 149 ms
30,236 KB
testcase_47 AC 151 ms
30,212 KB
testcase_48 AC 157 ms
30,148 KB
testcase_49 AC 154 ms
30,060 KB
testcase_50 AC 155 ms
30,100 KB
testcase_51 AC 157 ms
29,928 KB
testcase_52 AC 175 ms
30,064 KB
testcase_53 AC 172 ms
30,012 KB
testcase_54 AC 170 ms
30,048 KB
testcase_55 AC 161 ms
30,044 KB
testcase_56 AC 134 ms
29,628 KB
testcase_57 AC 134 ms
29,824 KB
testcase_58 AC 138 ms
29,756 KB
testcase_59 AC 147 ms
30,072 KB
testcase_60 AC 134 ms
29,744 KB
testcase_61 AC 151 ms
60,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def mult(A, B):
    C = np.dot(A, B)
    C[C >= 1] = 1
    return C

def mat_pow(A, n):
    if n == 0:
        return np.eye(len(A), dtype=np.int64)
    X = mat_pow(A, n // 2)
    X = mult(X, X)
    return mult(A, X) if n & 1 else X

N, M, T = map(int, readline().split())
A = np.zeros((N, N), np.int64)
m = map(int, read().split())
for frm, to in zip(m, m):
    A[to, frm] += 1

B = mat_pow(A, T)
ans = B[:, 0].sum()
if ans == 0:
    ans = -1
print(ans)
0