結果

問題 No.1340 おーじ君をさがせ
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-05-01 12:37:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 81,836 KB
最終ジャッジ日時 2023-09-27 02:25:55
合計ジャッジ時間 20,607 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,460 KB
testcase_01 AC 72 ms
71,352 KB
testcase_02 AC 72 ms
71,220 KB
testcase_03 AC 70 ms
71,136 KB
testcase_04 AC 69 ms
71,600 KB
testcase_05 AC 69 ms
71,372 KB
testcase_06 AC 70 ms
71,388 KB
testcase_07 AC 70 ms
71,500 KB
testcase_08 AC 69 ms
71,264 KB
testcase_09 AC 69 ms
71,152 KB
testcase_10 AC 81 ms
76,264 KB
testcase_11 AC 248 ms
77,224 KB
testcase_12 AC 106 ms
76,564 KB
testcase_13 AC 358 ms
77,484 KB
testcase_14 AC 441 ms
77,192 KB
testcase_15 AC 379 ms
76,896 KB
testcase_16 AC 101 ms
76,496 KB
testcase_17 AC 178 ms
76,776 KB
testcase_18 AC 255 ms
77,300 KB
testcase_19 AC 88 ms
76,328 KB
testcase_20 AC 80 ms
76,596 KB
testcase_21 AC 281 ms
77,852 KB
testcase_22 AC 1,145 ms
81,836 KB
testcase_23 AC 277 ms
77,884 KB
testcase_24 AC 1,010 ms
78,664 KB
testcase_25 AC 119 ms
77,700 KB
testcase_26 AC 117 ms
77,852 KB
testcase_27 AC 109 ms
77,592 KB
testcase_28 AC 128 ms
77,712 KB
testcase_29 AC 103 ms
77,496 KB
testcase_30 AC 295 ms
77,832 KB
testcase_31 AC 1,021 ms
78,444 KB
testcase_32 AC 959 ms
78,388 KB
testcase_33 AC 948 ms
78,404 KB
testcase_34 AC 865 ms
78,124 KB
testcase_35 AC 1,027 ms
78,476 KB
testcase_36 AC 72 ms
71,216 KB
testcase_37 AC 100 ms
77,420 KB
testcase_38 AC 1,018 ms
78,448 KB
testcase_39 AC 332 ms
78,036 KB
testcase_40 AC 345 ms
77,784 KB
testcase_41 AC 344 ms
78,080 KB
testcase_42 AC 78 ms
76,308 KB
testcase_43 AC 77 ms
76,268 KB
testcase_44 AC 79 ms
76,384 KB
testcase_45 AC 79 ms
76,560 KB
testcase_46 AC 277 ms
77,904 KB
testcase_47 AC 286 ms
77,876 KB
testcase_48 AC 310 ms
78,056 KB
testcase_49 AC 288 ms
77,128 KB
testcase_50 AC 288 ms
77,356 KB
testcase_51 AC 289 ms
77,408 KB
testcase_52 AC 485 ms
77,224 KB
testcase_53 AC 472 ms
77,252 KB
testcase_54 AC 485 ms
77,412 KB
testcase_55 AC 405 ms
77,852 KB
testcase_56 AC 78 ms
76,436 KB
testcase_57 WA -
testcase_58 AC 74 ms
71,384 KB
testcase_59 AC 201 ms
76,652 KB
testcase_60 AC 72 ms
71,632 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7

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

def mat_pow(a, k):
    if k == 1: return a
    n = len(a)
    res = [[0] * n for i in range(n)]
    for i in range(n):
        res[i][i] = 1
    while k:
        if k & 1:
            res = mat_mul(res, a)
        a = mat_mul(a, a)
        k >>= 1
    return res

n, m, t = map(int, input().split())
G = [[0] * n for i in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    G[a][b] = 1
G2 = mat_pow(G, t)
ans = 0
for i in range(n):
    if G2[0][i] > 0:
        ans += 1
print(ans)
0