結果

問題 No.1340 おーじ君をさがせ
ユーザー nephrologistnephrologist
提出日時 2021-01-15 23:29:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,026 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2024-05-05 03:04:17
合計ジャッジ時間 15,400 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
65,280 KB
testcase_01 AC 47 ms
58,496 KB
testcase_02 AC 41 ms
52,480 KB
testcase_03 AC 41 ms
52,096 KB
testcase_04 WA -
testcase_05 AC 42 ms
52,352 KB
testcase_06 WA -
testcase_07 AC 42 ms
52,480 KB
testcase_08 AC 42 ms
51,840 KB
testcase_09 AC 41 ms
52,224 KB
testcase_10 AC 72 ms
67,456 KB
testcase_11 AC 803 ms
76,544 KB
testcase_12 WA -
testcase_13 AC 748 ms
76,928 KB
testcase_14 AC 1,626 ms
76,544 KB
testcase_15 AC 1,355 ms
76,032 KB
testcase_16 AC 151 ms
72,704 KB
testcase_17 AC 490 ms
76,288 KB
testcase_18 AC 822 ms
75,904 KB
testcase_19 AC 95 ms
68,224 KB
testcase_20 AC 63 ms
64,128 KB
testcase_21 AC 838 ms
76,160 KB
testcase_22 TLE -
testcase_23 AC 835 ms
76,160 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline
#  nxnの行列積
# n is necessary


n, m, t = map(int, input().split())

graph = [[0] * (n) for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a][b] = 1


#  nxnの行列積
# n is necessary
mod = 10 ** 9 + 7


def matrix_product(A, B, mod):
    res = [[0] * n for _ 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 matrix_exponents(A, t, mod):
    res = [[0] * n for _ in range(n)]
    for i in range(n):
        res[i][i] = 1
    while t > 0:
        if t & 1 == 1:
            res = matrix_product(res, A, mod)
        A = matrix_product(A, A, mod)
        t //= 2
    return res


res1 = matrix_exponents(graph, t, 10 ** 9 + 7)
res2 = matrix_exponents(graph, t, 10 ** 9 + 9)
ans = 0

for j in range(n):
    if res1[0][j] > 0 and res2[0][j]:
        ans += 1

print(ans)
0